µce
Social Media Photo by Dawid Zawiła on Unsplash
µhtml based Custom Elements.
API In A Nutshell
Check out the test page or this code pen playground.
; ;
Without classes, how does one define private properties?
Private properties can be created via a WeakMap, which is indeed how Babel transforms these anyway.
const privates = ;;
Without classes, how does one extend other components?
Object literals have been used as mixin for a very long time, and the pattern in here would likely be very similar.
The only warning is that Object.assign
, as well as object {...spread}
, lose getters and setters in the process, so that if you want to extend more complex components, you should consider using assignProperties, or a similar helper.
;const mixin = ; // a component literal definitionconst NamedElement = { return thistagName; }; // a generic NamedElement mixinconst FirstComponent = ; // define it via the FirstComponent mixin; // define it via mixin;