SlideShare a Scribd company logo
Maeda Naohito 
Welcome to the future. 
polymer 
2014/9/25
polymer? 
polymer elements ᵓ⠏䛥䜜䛯䠄UI/㠀UI䠅䜶䝺䝯䞁䝖㒆 
polymer.js Web Components䜢౽฼䛻౑䛖䝷䜲䝤䝷䝸 
platform.js Web Components䛾polyfill 
Web Components Webᶆ‽
Web Components? 
W3C䛷⟇ᐃ୰䛾䠐䛴䛾Webᶆ‽䛾䝁䝺䜽䝅䝵䞁 
Custom 
Elements 
HTML 
Import Templates Shadow 
DOM
䛺䛻䛜䛷䛝䜛䛾?
Web䛾(UI)㒊ရ䜢䝁䞁䝫䞊䝛䞁䝖໬䛷䛝䜛 
<google-map lat=’122’ lng=’23’></google-map> 
<tweet-button></tweet-button> 
<qr-code text=”hoge”></qr-code> 
<mini-dora color=”yellow”></mini-dora>
kwsk
Custom Elements 
䜹䝇䝍䝮せ⣲䜢ᐃ⩏ 
var XElemProto = Object.create(HTMLElement.prototype); 
var XElement = document.registerElement('x-element', { 
prototype: XElemProto 
}); 
registerElement()䛷Ⓩ㘓䚹 
prototype䜢Ώ䛩䚹 
䝝䜲䝣䞁䛿ᚲ㡲䚹
Custom Elements 
䜹䝇䝍䝮せ⣲䛻䝥䝻䝟䝔䜱䞉䝯䝋䝑䝗䜢ᐃ⩏ 
var XElemProto = Object.create(HTMLElement.prototype); 
XElemProto.foo = function() {…}; 
Object.defineProperty(XElemProto, "bar", {value:5}); 
var XElement = document.registerElement('x-element', { 
prototype: XElemProto 
})䠗 
foo䝯䝋䝑䝗䜢ᐃ⩏ 
bar䝥䝻䝟䝔䜱䜢ᐃ⩏
Custom Elements 
䜹䝇䝍䝮せ⣲䛾䝷䜲䝣䝃䜲䜽䝹䝁䞊䝹䝞䝑䜽 
var XElemProto = Object.create(HTMLElement.prototype); 
XElemProto.foo = function() {…}; 
XElemProto.createdCallback = function() { 
this.innerHTML = "<p>䜋䛢䜋䛢</p>"; 
䜹䝇䝍䝮せ⣲䛾䜲䞁䝇䝍䞁䝇䛜స䜙 
䜜䛯䛸䛝䛻࿧䜀䜜䜛䝁䞊䝹䝞䝑䜽䚹 
せ⣲䛻HTML䜢㏣ຍ䚹 
}; 
Object.defineProperty(XElemProto, "bar", {value:5}); 
....
Custom Elements 
䜹䝇䝍䝮せ⣲䜢䜲䞁䝇䝍䞁䝇໬ 
var xElem = new XElement(); 
document.body.appendChild(xElem); 
var xElem = document.createElement(`x-element`); 
<x-element></x-element>
Point 
⊂⮬䛾䜶䝺䝯䞁䝖䜢ᐃ⩏䛷䛝䜛䚹 
䜶䝺䝯䞁䝖䛻䝥䝻䝟䝔䜱/䝯䝋䝑䝗䜢ᐃ⩏䛷䛝䜛䚹 
䝷䜲䝣䝃䜲䜽䝹䝁䞊䝹䝞䝑䜽䛸࿧䜀䜜䜛㛵ᩘ䛜䛒䜛䚹
Templates 
Template䜢ᐉゝ 
<template id="mytemplate"> 
<img src="" alt="great image"> 
<div class="comment"></div> 
<script>alert(“hoge”);</script> 
</template> 
<template>䝍䜾䛷ᐉゝ 
<img>䛿src䜢ㄞ䜏䛻䛔䛛䛺䛔 
<script>䜒ᐇ⾜䛥䜜䛺䛔
Templates 
Template䜢Activate 
<template id="mytemplate">...</template> 
<script> 
var t = document.getElementById('mytemplate'); 
t.content.querySelector('img').src = 'logo.png'; 
var clone = document.importNode(t.content, true); 
document.body.appendChild(clone); 
</script> 
DOM䛸䛧䛶ᢅ䛘䜛 
Activate䛥䜜䛶ึ䜑䛶src䜢 
ྲྀ䜚䛻⾜䛳䛯䜚䚸 script䜢ᐇ 
⾜䛧䛯䜚䛩䜛䚹
Templates 
䝷䜲䝣䝃䜲䜽䝹䝁䞊䝹䝞䝑䜽ෆ䛷Template䜢౑䛖 
XElemProto.createdCallback = function() { 
var t = document.getElementById('x-elem-template'); 
var clone = document.importNode(t.content, true); 
this.appendChild(clone); 
䡙 
䜹䝇䝍䝮䜶䝺䝯䞁䝖䛜䜲䞁䝇䝍䞁䝇໬䛥䜜䛯᫬ 
Ⅼ䛷template䜢ὶ䛧㎸䜐䚹
Point 
● activate䛥䜜䜛䜎䛷䚸ືస䛧䛺䛔䚹 
● ᩥᏐิ䛷䛿䛺䛟DOM䛸䛧䛶ᢅ䛘䜛䛾䛷ᢅ䛔䜔䛩 
䛔䚹
Shadow DOM 
ShadowRoot䜢సᡂ 
XElemProto.createdCallback = function() { 
var shadow = this.createShadowRoot(); 
shadow.innerHTML = "<b>䜋䛢䜋䛢</b>"; 
䡙 
shadowRoot䜢సᡂ 
shadowRootୗ䛿ู䝇䝁䞊䝥䛸 
䛺䜚䚸እ㒊䛻ᙳ㡪䛧䛺䛔䚹
Shadow DOM 
ShadowRoot䛻Template䜢ᒎ㛤 
<template id="x-elem-template"> 
<style>p { color: orange; } </style> 
... 
var shadow = this.createShadowRoot(); 
var t = document.getElementById('x-elem-template'); 
var clone = document.importNode(t.content, true); 
shadow.appendChild(clone) 
template䛻style䜢ྵ䜐 
shadowDOMෆ䛻ᒎ㛤䛥䜜䛯 
style䛿እ㒊䛻ᙳ㡪䛧䛺䛔
Point 
● Shadow Rootෆ䛾䝇䝁䞊䝥䛿እ㒊䛻ᙳ㡪䛧䛺䛔 
● style䛾䜹䝥䝉䝹໬䛜ྍ⬟
HTML Import 
html䜢import 
main.html 
<head> 
<link rel="import" href="xelement.html"> 
</head> 
1䛴䛾URL䜢import䛩䜛䛾䜏 
import䛥䜜䜛html䛜css/js➼䛾 
link䜢ྵ䜐 
xelement.html 
<link rel="import" href="xelement.html"> 
<script src="jquery.js"></script> 
<template>...
Point 
HTML/CSS/Javascript䜢䠍䛴䛾URL䛷䝞䞁䝗䝸䞁 
䜾䛷䛝䜛
⤖ᒁ䛺䛻䛜䛔䛔䛾?
෌฼⏝䛷䛝䜛 
<mini-dora color=”yellow”></mini-dora> 
<mini-dora color=”green”></mini-dora> 
<mini-dora color=”red”></mini-dora> 
<mini-dora color=”yellow”></mini-dora> 
<mini-dora color=”green”></mini-dora>
ศᴗ䛷䛝䜛 
䝥䝻䜾䝷䝬: 
䝁䞁䝫䞊䝛䞁䝖㛤Ⓨ(html, js) 
䝕䝄䜲䝘䞊: 
䝕䝄䜲䞁(css) 
䝁䞊䝎䞊 
㟼ⓗ䝁䞊䝕䜱䞁䜾(html, 
css)
ᶆ‽ 
UI䛾䝁䞁䝫䞊䝛䞁䝖໬䛾᪉ἲ 
䝣䝺䞊䝮䝽䞊䜽䛻䜘䛳䛶䝞䝷䝞䝷 
Webᶆ‽
Semantic! 
<div id=”blue-circle”> 
<div class=”w-c”>...</div> 
<div class=”w-c”>...</div> 
<div id=”red-c”>...</div> 
… 
䝗䝷..䛘䜒..䜣? 
<x-doraemon></x-draemon> 
䝗䝷䛘䜒䜣!
polymer䛾ヰ䛿?
Web Components䜢౑䛔䜔䛩䛟 
without polymer 
<template id=”xtemplate”>...</template> 
<script> 
var XElm= document.registerElement(‘x-element’),{ 
prototype:{ 
createdCallback: function(){ 
var t = document.equalSelector(‘xtemplate’); 
var c = document.importNode(t.content, true); 
var shadow = this.createShadowRoot(); 
shadow.appendChild(c); 
} 
} 
}); 
</script>
Web Components䜢౑䛔䜔䛩䛟 
with polymer 
<polymer-element name=”x-element”> 
䚷<template>...</template> 
</polymer-element> 
䛔䛔ឤ䛨䛻wrap䛧䛶䛟䜜䛶䜛䚹
Web Components+α 
Web Animations 
Two way bindings 
Layout Attributes 
Gestures 
䛔䜝䛔䜝䛒䜛䜘䛖䛷䛩䛜๭ឡ䛧䜎䛩.
One More Thing
polymer Designer 
GUI䛷polymer element䜢స䜜䜛䝒䞊䝹
ARIGATO!

More Related Content

PDF
Polymer & the web components revolution 6:25:14
PDF
Polymer
PDF
Web Components with Polymer (extra Polymer 2.0)
PDF
Polymer vs other libraries (Devfest Ukraine 2015)
PPTX
Google Polymer Introduction
PPTX
How to build a web application with Polymer
PPTX
Polymer and web component
PDF
Introduction to polymer project
Polymer & the web components revolution 6:25:14
Polymer
Web Components with Polymer (extra Polymer 2.0)
Polymer vs other libraries (Devfest Ukraine 2015)
Google Polymer Introduction
How to build a web application with Polymer
Polymer and web component
Introduction to polymer project

What's hot (20)

PDF
Google Polymer Framework
PDF
Web Components
PDF
Web Components & Polymer 1.0 (Webinale Berlin)
PDF
Introduction to Web Components
PPTX
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
PPTX
Polymer
PDF
Web Components and Modular CSS
PDF
Unlock the next era of UI design with Polymer
PDF
Introduction to web components
PDF
Levent-Gurses' Introduction to Web Components & Polymer
PPTX
Web Components: Web back to future.
PDF
Web Components + Backbone: a Game-Changing Combination
PDF
A brave new web - A talk about Web Components
PDF
The Complementarity of React and Web Components
PDF
Introduction to Web Components
PDF
Web Components Everywhere
PDF
Web Components for Java Developers
PDF
Chrome enchanted 2015
PDF
Vaadin Components @ Angular U
PPTX
Google Polymer Framework
Web Components
Web Components & Polymer 1.0 (Webinale Berlin)
Introduction to Web Components
The rise of Polymer and Web Components (Kostas Karolemeas) - GreeceJS #17
Polymer
Web Components and Modular CSS
Unlock the next era of UI design with Polymer
Introduction to web components
Levent-Gurses' Introduction to Web Components & Polymer
Web Components: Web back to future.
Web Components + Backbone: a Game-Changing Combination
A brave new web - A talk about Web Components
The Complementarity of React and Web Components
Introduction to Web Components
Web Components Everywhere
Web Components for Java Developers
Chrome enchanted 2015
Vaadin Components @ Angular U
Ad

Viewers also liked (20)

PDF
Polymer
PPTX
Web Components
PDF
Devoxx France - Web Components, Polymer et Material Design
PDF
2014 03-25 - GDG Nantes - Web Components avec Polymer
PDF
Angular js gtg-27feb2013
PDF
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
PPTX
Material design
PDF
Tech talk polymer
PDF
The Beautiful Simplicity of ES2015
PDF
Web components
PDF
Polymer and Firebase: Componentizing the Web in Realtime
PPTX
Material Design - do smartphone ao desktop
PDF
Um salve para evolução! construindo uma nova web com polymer
PDF
Apresentação Google I/O Extended Vitória
PDF
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
PDF
Polymer Starter Kit
PDF
WebApps com Web Components
PDF
O futuro do Android
PDF
Introduction To Dart (GDG NY Jan 2014 Meetup)
PDF
Workshop de Web Components
Polymer
Web Components
Devoxx France - Web Components, Polymer et Material Design
2014 03-25 - GDG Nantes - Web Components avec Polymer
Angular js gtg-27feb2013
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Material design
Tech talk polymer
The Beautiful Simplicity of ES2015
Web components
Polymer and Firebase: Componentizing the Web in Realtime
Material Design - do smartphone ao desktop
Um salve para evolução! construindo uma nova web com polymer
Apresentação Google I/O Extended Vitória
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Polymer Starter Kit
WebApps com Web Components
O futuro do Android
Introduction To Dart (GDG NY Jan 2014 Meetup)
Workshop de Web Components
Ad

Similar to Polymer, A Web Component Polyfill Library (20)

PDF
Devoxx 2014-webComponents
PDF
The Road to Native Web Components
PDF
Michael North "The Road to Native Web Components"
PDF
Modern Web UI - Web components
PDF
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
PDF
Real World Web components
PPTX
Up & Running with Polymer
PPTX
Web Components Revolution
PDF
Polytechnic 1.0 Granada
PDF
Polymer 1.0
PDF
Human Talks - StencilJS
PPTX
Polytechnic speaker deck oluwadamilare
PPTX
Polytechnic speaker deck oluwadamilare
PPTX
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
PDF
Web components
PDF
Polymer Web Framework - Swecha Boot Camp
PDF
Polymer Polytechnic George Town 2014
PDF
Polymer - pleasant client-side programming with web components
PPTX
Web Components: Introduction and Practical Use Cases
PDF
Web components are the future of the web - Take advantage of new web technolo...
Devoxx 2014-webComponents
The Road to Native Web Components
Michael North "The Road to Native Web Components"
Modern Web UI - Web components
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
Real World Web components
Up & Running with Polymer
Web Components Revolution
Polytechnic 1.0 Granada
Polymer 1.0
Human Talks - StencilJS
Polytechnic speaker deck oluwadamilare
Polytechnic speaker deck oluwadamilare
Iasi code camp 12 october 2013 shadow dom - mihai bîrsan
Web components
Polymer Web Framework - Swecha Boot Camp
Polymer Polytechnic George Town 2014
Polymer - pleasant client-side programming with web components
Web Components: Introduction and Practical Use Cases
Web components are the future of the web - Take advantage of new web technolo...

Recently uploaded (20)

PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PDF
Testing WebRTC applications at scale.pdf
PPTX
INTERNET------BASICS-------UPDATED PPT PRESENTATION
DOCX
Unit-3 cyber security network security of internet system
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
SAP Ariba Sourcing PPT for learning material
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
Introduction to Information and Communication Technology
PDF
Decoding a Decade: 10 Years of Applied CTI Discipline
PPTX
artificial intelligence overview of it and more
PDF
RPKI Status Update, presented by Makito Lay at IDNOG 10
PPTX
international classification of diseases ICD-10 review PPT.pptx
PDF
Introduction to the IoT system, how the IoT system works
PPTX
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
PDF
Sims 4 Historia para lo sims 4 para jugar
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
Testing WebRTC applications at scale.pdf
INTERNET------BASICS-------UPDATED PPT PRESENTATION
Unit-3 cyber security network security of internet system
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
WebRTC in SignalWire - troubleshooting media negotiation
introduction about ICD -10 & ICD-11 ppt.pptx
522797556-Unit-2-Temperature-measurement-1-1.pptx
SAP Ariba Sourcing PPT for learning material
The Internet -By the Numbers, Sri Lanka Edition
PptxGenJS_Demo_Chart_20250317130215833.pptx
Introduction to Information and Communication Technology
Decoding a Decade: 10 Years of Applied CTI Discipline
artificial intelligence overview of it and more
RPKI Status Update, presented by Makito Lay at IDNOG 10
international classification of diseases ICD-10 review PPT.pptx
Introduction to the IoT system, how the IoT system works
CHE NAA, , b,mn,mblblblbljb jb jlb ,j , ,C PPT.pptx
Sims 4 Historia para lo sims 4 para jugar

Polymer, A Web Component Polyfill Library