© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
Introduction to Web Compoents
Ran Wahle
http://blogs.mocrosoft.co.il/ranw
HTML so far
Loosing the pyramid of doom
Custom Elements
Templates
HTML imports
Shadow DOM
HTML so far
Script tags in one area
CSS tags in another
HTML content in another
Custom Elements
Teaching the browser about new elements
Creating callbacks
Remember this?
<script type="text/template">
<div>
<h1>My template content</h1>
… some content …
</div>
</script>
Templates
HTML
<template id="template">
<div>
<h1>Web Components</h1>
<img src="http://webcomponents.org/img/logo.svg">
</div>
</template>
.
.
<div id="host"></div>
Templates
javascript
var template = document.querySelector('#template');
var clone = document.importNode(template.content, true);
var host = document.querySelector('#host');
host.appendChild(clone);
Templates
HTML Imports
#include on the web
New ‘link’ tag on the head part
You can host it anywhere in the file.
Shadow DOMs
Encapsulate styling
Separate content from presentation
Browser support (Current status, may 26th)
Can we start already?
Yes
You may implement web components in existing apps
You may use polyfills for old browsers
Summary
Web Components helps as loose the HTML pyramid of doom
Fully supported by Chrome and Opera
You may use it in other browsers with polyfill (webcomponnet.js).
Resources:
http://webcomponents.org
https://twitter.com/Web_Components
My blog: http://blogs.Microsoft.co.il/ranw
Questions
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com
Tank you
Ran Wahle
ranw@sela.co.il

Introduction to web compoents