4 specifications
Include an HTML element inside another one
HTML and CSS are just loaded but not included (available) We retrieve the content using the import property
Load and Error Event
Browsers already use it
It's all about Encapsulation
Hello
Hello too
Bla Bla Bla
Reusable DOM template
No side effect
Declaration vs register
register
var myElemtProto = Object.create(HTMLElement.prototype);
myElemtProto.createdCallback = function() {};
var myElemt = document.registerElement('my-element', myElemtProto);
myEltProto.createdCallback = function() {
this.innerHTML = "un peu de contenu!";
};
myEltProto.createdCallback = function() {
var shadow = this.createShadowRoot();
shadow.innerHTML = "un peu de contenu!";
};
myEltProto.createdCallback = function() {
var t = document.querySelector('#sdtemplate');
var clone = document.importNode(t.content, true);
this.createShadowRoot().appendChild(clone);
};
myEltProto.myFctn=function(){...}
Object.defineProperty(myEltProto, "bar", {value: 5});
Can be used alone
But a weak support
So what can we do ?
Credits: Eric Bidelman,Rob Dodson,Dominic Cooney