Skip to content

Commit 8d898d7

Browse files
authored
fix(icon): sanitizer checks attribute name instead of value (#1087)
resolves #1088
1 parent 7dd6909 commit 8d898d7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/components/icon/test/validate.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ describe('isValid', () => {
77
const el = {
88
nodeType: 1,
99
nodeName: 'svg',
10-
attributes: [{ value: 'onload' }],
10+
attributes: [{ name: 'onload' }],
1111
childNodes: []
1212
} as any;
1313
expect(isValid(el)).toBe(false);
@@ -17,7 +17,7 @@ describe('isValid', () => {
1717
const el = {
1818
nodeType: 1,
1919
nodeName: 'svg',
20-
attributes: [{ value: 'OnClIcK' }],
20+
attributes: [{ name: 'OnClIcK' }],
2121
childNodes: []
2222
} as any;
2323
expect(isValid(el)).toBe(false);

src/components/icon/validate.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export const isValid = (elm: HTMLElement) => {
3434
}
3535

3636
for (let i = 0; i < elm.attributes.length; i++) {
37-
const val = elm.attributes[i].value;
38-
if (isStr(val) && val.toLowerCase().indexOf('on') === 0) {
37+
const name = elm.attributes[i].name;
38+
if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {
3939
return false;
4040
}
4141
}

0 commit comments

Comments
 (0)