Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

Yehor Lvivski

@lvivski

Web Components

Facebook

Delphi

jQuery Era

$('input').datePicker()

jQuery Cons

Sencha (ExtJS)

Twitter

BEM

BEM.block('date-picker', {...}) {block: 'date-picker'}

AngularJS

        angular.directive(
          'mega-tag', function() {
          return {
            restrict: 'E',
            link: function
              (scope, element, attrs)
              {...}
          }
        })
      

AngularJS

<mega-tag></mega-tag>

ReactJS

        React.createClass({
          render: function() {
            return (<div>
            {this.props.awesome}
            </div>)
          }
        })
      

W3C

Web Components

<x-button>WASSUP</x-button>

Web Components

Introduction to Web Components

Templates

HTML is not a String

        <template id="awesome">
          <img src="">
          <div class="title"></div>
        </template>
      
HTML Templates
        var t = document
    .querySelector('#awesome')
        t.content
    .querySelector('img')
    .src = 'http://...'
        var c = document
    .importNode(t.content, true)
        document.body.appendChild(c)
      

Shadow DOM

Shadow DOM

w3c spec

Shadow DOM

        <div id="host">
        <h1>Normal DOM</h1>
        </div>
      

        var shadow = document
    .querySelector('#host')
    .createShadowRoot()
        shadow.innerHTML = '<div>Shadow DOM</div>'
      

Normal DOM

Shadow Pseudo

        <style>
          #host::x-pseudo {
          color: blue
          }
        </style>
        <div id="host"></div>
        <script>
        document
  .querySelector('#host')
  .createShadowRoot()
  .innerHTML =
  '<div pseudo="x-pseudo">\
  </div>'
        </script>
      

CSS Variables

        x-tag {
          color: var(tag-color);
          font: var(tag-font)}
      

        #host {
          var-tag-color: blue;
          var-tag-font: sans-serif}
      
CSS Custom Properties
        <div id="host">
        <h1>Normal DOM</h1>
        <div>other content</div>
        </div>
      

        <style>
        h1, h2 {font-size: 25pt}
        </style>
        <content select="h1"></content>
        <h2>sub header<h2>
        <content select="*"></content>
      
        <template id="tpl">
          <content></content>
        </template>
        <script>
        var XProto = 
    Object.create(HTMLElement.prototype)
        XProto.createdCallback = function() {
          var t = document
      .querySelector('#tpl')
          var c = document
      .importNode(t.content, true)
          this.createShadowRoot().appendChild(c)
        }
        document.register('x-tag', {
         prototype: XProto
        })</script>
      
        <link rel="import"
  href="x-tag.html">
        <x-tag>
          ...
        </x-tag>
      

I want to use it NOW

Thanks


lvivski