8000 Only warn about html() method once · electrikmilk/javascript-ui@2339863 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2339863

Browse files
committed
Only warn about html() method once
1 parent a385f14 commit 2339863

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/base-element.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
let references = {};
6+
let htmlWarn = false;
67

78
export class BaseElement {
89
element;
@@ -111,8 +112,9 @@ export class BaseElement {
111112
}
112113

113114
html(html) {
114-
if (import.meta.env.DEV) {
115+
if (import.meta.env.DEV && !htmlWarn) {
115116
console.warn('Do not use the html() method to render user generated content. This creates a risk of cross-site scripting (XSS) attacks.');
117+
htmlWarn = true;
116118
}
117119
return this.property('innerHTML', html);
118120
}

0 commit comments

Comments
 (0)
0