-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: skip dom purify for trusted content #393
Feat: skip dom purify for trusted content #393
Conversation
if (iconResult.trusted) { | ||
this.svgContent = iconResult.svgContent | ||
} else { | ||
const { default: DOMPurify } = await import('dompurify') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dom-purify is still pretty large so we can do following in the future.
- let users do sanitizing themselves
- leveraging https://developer.mozilla.org/en-US/docs/Web/API/HTML_Sanitizer_API
} | ||
if (Number.isNaN(size)) { | ||
throw new TypeError(`icon size must not be NaN`) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO] 実は Number.isFinite()
だけで良かったりしませんか?
if (!Number.isFinite(size)) {
throw new TypeError('icon size must be a finite number')
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1/0
やInfinity
を考えると確かにisFiniteが良さそうです。実際はかなりのedge caseですね
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
すみません意図としては typeof
が number
であるかの判定も isFinite() だけで行けるんじゃないですか、みたいなことでした(これでも良いですが)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4eb112c 消しました。元々エラー少しわかりやすくなるかもしれないという意図で入れていたが処理的には確か不要そうです
やったこと
動作確認環境
チェックリスト
不要なチェック項目は消して構いません