Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Web Components v1
Search
hemanth.hm
April 13, 2017
Programming
1
110
Web Components v1
Quick intro to Web Components v1
hemanth.hm
April 13, 2017
Tweet
Share
More Decks by hemanth.hm
See All by hemanth.hm
Rethink Async
gnumanth
1
89
Harmony with ES6!
gnumanth
6
1.2k
Ants and Algorithm
gnumanth
1
120
NoSQL?
gnumanth
1
250
Google's whitepaper
gnumanth
3
130
Python Intro
gnumanth
1
390
Other Decks in Programming
See All in Programming
note の Elasticsearch 更新系を支える技術
tchov
3
680
AIコーディングの理想と現実
tomohisa
33
36k
Ruby on Railroad: The Power of Visualizing CFG
ydah
0
260
MCP調べてみました! / Exploring MCP
uhzz
2
2.3k
Ruby's Line Breaks
yui_knk
3
2k
Making TCPSocket.new "Happy"!
coe401_
1
2.4k
The Missing Link in Angular’s Signal Story: Resource API and httpResource
manfredsteyer
PRO
0
110
KawaiiLT 登壇資料 キャリアとモチベーション
hiiragi
0
160
iOSアプリで測る!名古屋駅までの 方向と距離
ryunakayama
0
130
Amazon CloudWatchの地味だけど強力な機能紹介!
itotsum
0
200
Qiita Bash
mercury_dev0517
2
220
Cursorを活用したAIプログラミングについて 入門
rect
0
120
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
68
11k
How STYLIGHT went responsive
nonsquared
100
5.5k
What's in a price? How to price your products and services
michaelherold
245
12k
Why Our Code Smells
bkeepers
PRO
336
57k
GraphQLとの向き合い方2022年版
quramy
46
14k
The Language of Interfaces
destraynor
157
25k
Side Projects
sachag
453
42k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
2.9k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
GitHub's CSS Performance
jonrohan
1030
460k
It's Worth the Effort
3n
184
28k
Transcript
Web Componentes
· <template> tag · HTML imports · Shadow DOM ·
Custom Elements
<template>
'content' in document.createElement('template');
Activating <template>: var t = document.querySelector('#aweTemplate'); var clone = document.importNode(t.content,
true); document.body.appendChild(clone);
DEMO
HTML imports
'import' in document.createElement('link');
<link rel="import" href="/imports/aweTemplate.html"> <link rel="import" href="/imports/aweTemplate.html" onload="handleLoad(event)" onerror="handleError(event)">
const link = document.querySelector('link[rel=import]'); const xkcd = link.import; // Access
DOM of the document in aweTemplate const cartoon = xkcd.querySelector('img');
const aweDoc = document.currentScript.ownerDocument;
DEMO
Shadow DOM
const supportsShadowDOMV1 = !!HTMLElement.prototype.attachShadow;
const host = document.body.createShadowRoot(); host.innerHTML = "<p>I'm a <em>shadow</em> dom!</p>";
document.appendChild(host);
DEMO
Custom Elements
const supportsCustomElements = 'customElements' in window;
class AweElement extends HTMLElement {...} window.customElements.define('awe-element', AppDrawer);
window.customElements.define('awe-element', class extends HTMLElement {...});
class AweElement extends HTMLElement { constructor() { super(); // Don't
forget ... } connectedCallback() { ... } disconnectedCallback() { ... } attributeChangedCallback(attrName, oldVal, newVal) { ... } }
None
DEMO
None
None
h3manth.com @gnumanth
None