Skip to content

Commit 60d048a

Browse files
committed
refactor: use forof to iterate over attributes
1 parent f2c7e97 commit 60d048a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/dom-wrapper.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ export class DOMWrapper<ElementType extends Element> {
2323
attributes(): { [key: string]: string }
2424
attributes(key: string): string
2525
attributes(key?: string): { [key: string]: string } | string {
26-
const attributes = this.element.attributes
26+
const attributes = Array.from(this.element.attributes)
2727
const attributeMap: Record<string, string> = {}
28-
for (let i = 0; i < attributes.length; i++) {
29-
const att = attributes.item(i)!
30-
attributeMap[att.localName] = att.value
28+
for (const attribute of attributes) {
29+
attributeMap[attribute.localName] = attribute.value
3130
}
3231

3332
return key ? attributeMap[key] : attributeMap

0 commit comments

Comments
 (0)