Skip to content

Commit b99c22d

Browse files
koddssonkeithamus
andcommitted
Make attrs configurable
Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
1 parent eab4015 commit b99c22d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/attr.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export function initializeAttrs(instance: HTMLElement, names?: Iterable<string>)
4040
const value = (<Record<PropertyKey, unknown>>(<unknown>instance))[key]
4141
const name = attrToAttributeName(key)
4242
let descriptor: PropertyDescriptor = {
43+
configurable: true,
4344
get(this: HTMLElement): string {
4445
return this.getAttribute(name) || ''
4546
},
@@ -49,6 +50,7 @@ export function initializeAttrs(instance: HTMLElement, names?: Iterable<string>)
4950
}
5051
if (typeof value === 'number') {
5152
descriptor = {
53+
configurable: true,
5254
get(this: HTMLElement): number {
5355
return Number(this.getAttribute(name) || 0)
5456
},
@@ -58,6 +60,7 @@ export function initializeAttrs(instance: HTMLElement, names?: Iterable<string>)
5860
}
5961
} else if (typeof value === 'boolean') {
6062
descriptor = {
63+
configurable: true,
6164
get(this: HTMLElement): boolean {
6265
return this.hasAttribute(name)
6366
},
@@ -93,6 +96,7 @@ function attrToAttributeName(name: string): string {
9396
export function defineObservedAttributes(classObject: CustomElement): void {
9497
let observed = classObject.observedAttributes || []
9598
Object.defineProperty(classObject, 'observedAttributes', {
99+
configurable: true,
96100
get() {
97101
const attrMap = getAttrNames(classObject.prototype)
98102
return [...attrMap].map(attrToAttributeName).concat(observed)

0 commit comments

Comments
 (0)