28. Shadow DOM 201
โ ํจ์ํ :host()
:host(x-foo:host) {
/* Applies if the host is a <x-foo> element.*/
}
:host(x-bar:host) {
/* Applies if the host is a <x-bar> element. */
}
:host(div) { {
/* Applies if the host element or an ancestor is a <div>. */
}
29. Shadow DOM 201
โ hat - ^
<style>
#host ^ span {
color: red;
}
</style>
<div id="host">
<span>Light DOM</span>
</div>
<script>
var host = document.querySelector('div');
var root = host.createShadowRoot();
root.innerHTML = "<span>Shadow DOM</span>" +
"<content></content>";
</script>
40. HTML Template
โ HTML Template ์ด์
โ Text Templating
โ Script Overloading
โ <script type=โtext/template></script>
โ Offline DOM
โ ๋ณด์ด์ง ์๋ DOM
41. HTML Template
โ HTML Template ์ด์
โ Text Templating
โ Script Overloading
โ <script type=โtext/template></script>
โ Offline DOM
โ ๋ณด์ด์ง ์๋ DOM
42. HTML Template
โ ์ง์ ์ฌ๋ถ ๊ฒ์ฌ
function supportsTemplate() {
return 'content' in document.createElement('template');
}
if (supportsTemplate()) {
// Good to go!
} else {
// Use old templating techniques or libraries.
}
53. HTML Imports
โ ์ฝ์ ์
<head>
<link rel="import" href="warnings.html">
</head>
<body>
...
<script>
var link = document.querySelector('link[rel="import"]');
var content = link.import;
// Grab DOM from warning.html's document.
var el = content.querySelector('.warning');
document.body.appendChild(el.cloneNode(true));
</script>
</body>
61. HTML5Rocks: Web Component Tutorials
โ Shadow DOM 101
โ Shadow DOM 201: CSS & Styling
โ Shadow DOM 301: Advanced Concepts & DOM API
โ HTML Imports: #include for Web
โ Custom Element: Defining new elements in HTML
โ HTMLโs new Template Tag: Standarizing client-side
templating
Further readings...
62. Resources
โ Introduction to Web Components
โ webcomponents.github.io
โ Polymer Project
โ Mozilla Brick
โ Yeoman.io