The Shadow DOM
API lets you see
the man behind
the curtain.
Slide 23
Slide 23 text
A problem
Shadow
DOM
CSS HTML
Slide 24
Slide 24 text
The problem
.foo { color: #f00; }
.foo { color: #00f; }
(^0_0^) (^_^;)
Slide 25
Slide 25 text
The Solution
Encapsulation
Slide 26
Slide 26 text
Encapsulation
1. Everything the thing needs
is contained within itself.
2. The thing doesn't interfere
with things outside itself, and
vice versa.
Slide 27
Slide 27 text
Encapsulation in HTML
Slide 28
Slide 28 text
Web Components
Better encapsulation
Slide 29
Slide 29 text
What are
Web Components
?
Slide 30
Slide 30 text
Web Components:
a set of emerging
standards aimed
at making
reusable widgets.
Slide 31
Slide 31 text
Web Components:
the biggest
change to web
dev since
XMLHttpRequest.
Slide 32
Slide 32 text
Shadow DOM
Templates
Custom elements
Decorators
Slide 33
Slide 33 text
Shadow DOM
Templates
Custom elements
Decorators
Slide 34
Slide 34 text
Mustache & Handlebars
<h2>Hello world!</h2>
Slide 35
Slide 35 text
The template element
Hello world!
Content
Slide 36
Slide 36 text
This markup is
inert.
Slide 37
Slide 37 text
The content object
var foo = document.getElementById('foo'),
bar = document.getElementById('bar'),
clone = foo.content.cloneNode(true);
bar.appendChild(clone);
Slide 38
Slide 38 text
Templates
State of the Browser
Hello world!
State of the Browser
Slide 39
Slide 39 text
This markup is
active.
Slide 40
Slide 40 text
{demo}
Slide 41
Slide 41 text
Templates
Slide 42
Slide 42 text
Templates
Slide 43
Slide 43 text
The content element
(insertion point)
Hello world!
Slide 44
Slide 44 text
The content element
Front End United
Front End United
Hello world!
Slide 45
Slide 45 text
The select attribute
Hello world!
I'm foo
I'm bar
Slide 46
Slide 46 text
oldEl += document.createElement('content');
Shadow DOM