Introduction to web compoents

16
© 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

Transcript of Introduction to web compoents

Page 1: Introduction to web compoents

© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com

Introduction to Web Compoents

Ran Wahlehttp://blogs.mocrosoft.co.il/ranw

Page 2: Introduction to web compoents

HTML so farLoosing the pyramid of doomCustom ElementsTemplatesHTML importsShadow DOM

Page 3: Introduction to web compoents

HTML so far

Script tags in one areaCSS tags in anotherHTML content in another

Page 4: Introduction to web compoents
Page 5: Introduction to web compoents

Custom Elements

Teaching the browser about new elementsCreating callbacks

Page 6: Introduction to web compoents

Remember this?

<script type="text/template"> <div> <h1>My template content</h1>

… some content … </div> </script>

Templates

Page 7: Introduction to web compoents

HTML

<template id="template">

<div> <h1>Web Components</h1> <img src="http://webcomponents.org/img/logo.svg"> </div></template>..<div id="host"></div>

Templates

Page 8: Introduction to web compoents

javascript

var template = document.querySelector('#template');var clone = document.importNode(template.content, true);var host = document.querySelector('#host');host.appendChild(clone);

Templates

Page 9: Introduction to web compoents

HTML Imports

#include on the webNew ‘link’ tag on the head partYou can host it anywhere in the file.

Page 10: Introduction to web compoents

Shadow DOMs

Encapsulate styling Separate content from presentation

Page 11: Introduction to web compoents

Browser support (Current status, may 26th)

Page 12: Introduction to web compoents

Can we start already?

YesYou may implement web components in existing appsYou may use polyfills for old browsers

Page 13: Introduction to web compoents

Summary

Web Components helps as loose the HTML pyramid of doomFully supported by Chrome and OperaYou may use it in other browsers with polyfill (webcomponnet.js).

Page 14: Introduction to web compoents

Resources:

http://webcomponents.orghttps://twitter.com/Web_ComponentsMy blog: http://blogs.Microsoft.co.il/ranw

Page 15: Introduction to web compoents

Questions

Page 16: Introduction to web compoents

© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com

Tank you

Ran [email protected]