application authors to define w idgets w ith a level of visual richness and interactivity not possible w ith CSS alone, and ease of composition and reuse not possible w ith script libraries today W3C
• Son contenu est parsé mais inerte (markup caché dans le DOM, pas de rendering) • Scripts non exécutés, images non loadées, audio non lu… • Le contenu « n’appartient pas » au document (querySelector() renvoie null) ! La template peut être insérée n’importe où dans <head>, <body>, <frameset>. On peut aussi l’utiliser comme « enfant » d’un <table> ou d’un <select> !
presentation and API, that can be used in HTML documents CUSTOM ELEMENTS W3C • Créer de nouveaux éléments DOM/HTML • Etendre des éléments existants • « Packager » des fonctionnalités custom au sein d’un tag • Etendre l’API des éléments DOM existants • Interagir grâce aux Lifecycle Callbacks
: l’élément est créé ET enregistré InsertedCallback() : l’élément a été inséré dans le document RemovedCallback() : l’élément a été supprimé du document
p : //www. h t m l 5 ro c k s .co m /e n /t u tor i a l s / webcomponents/customelements/ ! • http://customelements.io/ ! • http://www.polymer-project.org/platform/custom- elements.html ! • http://bosonic.github.io/
DOM ont ce scope par défaut ! • Les règles CSS déclarés dans la page ne s’appliquent pas par défaut au Shadow DOM ! • On peut changer ce comportement avec shadow.applyAuthorStyles = true;
• https://developer.mozilla.org/en-US/Apps/ Tools_and_frameworks/Web_components ! • https://www.youtube.com/watch?v=e29D1daRYrQ ! • h tt p : //c o d i n g . s m a s h i n g m a g a z i n e . c o m / 2014/03/04/introduction-to-custom-elements/