1
0
mirror of https://github.com/jaandrle/deka-dom-el synced 2024-11-22 16:55:23 +01:00

Update customElement.js

This commit is contained in:
Jan Andrle 2024-01-04 16:08:02 +01:00
parent 89f9880277
commit 6f5e13e66a
Signed by: jaandrle
GPG Key ID: B3A25AED155AFFAB

View File

@ -43,6 +43,10 @@ function observedAttribute(instance, name){
export function observedAttributes(instance){ export function observedAttributes(instance){
const { observedAttributes= [] }= instance.constructor; const { observedAttributes= [] }= instance.constructor;
return observedAttributes return observedAttributes
.map(name=> [ name.replace(/-./g, x=> x[1].toUpperCase()), name ]) .reduce(function(out, name){
.reduce((out, [ key, name ])=> ( Reflect.set(out, key, observedAttribute(instance, name)), out ), {}); Reflect.set(out, kebabToCamel(name), observedAttribute(instance, name));
return out;
}, {});
;
} }
function kebabToCamel(name){ return name.replace(/-./g, x=> x[1].toUpperCase()); }