Skip to content

Commit 35e5326

Browse files
committed
refactor(attr): simplify Set|Array to Array
1 parent 37bf44b commit 35e5326

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/attr.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {CustomElement} from './custom-element'
22

3-
const attrs = new WeakMap<Record<PropertyKey, unknown>, Set<string>>()
3+
const attrs = new WeakMap<Record<PropertyKey, unknown>, string[]>()
44
type attrValue = string | number | boolean
55

66
/**
@@ -11,8 +11,8 @@ type attrValue = string | number | boolean
1111
* Number or Boolean. This matches the behavior of `initializeAttrs`.
1212
*/
1313
export function attr<K extends string>(proto: Record<K, attrValue>, key: K): void {
14-
if (!attrs.has(proto)) attrs.set(proto, new Set())
15-
attrs.get(proto)!.add(key)
14+
if (!attrs.has(proto)) attrs.set(proto, [])
15+
attrs.get(proto)!.push(key)
1616
}
1717

1818
/**
@@ -85,7 +85,7 @@ export function defineObservedAttributes(classObject: CustomElement): void {
8585
get() {
8686
const attrMap = attrs.get(classObject.prototype)
8787
if (!attrMap) return observed
88-
return [...attrMap].map(attrToAttributeName).concat(observed)
88+
return attrMap.map(attrToAttributeName).concat(observed)
8989
},
9090
set(attributes: string[]) {
9191
observed = attributes

0 commit comments

Comments
 (0)