SlideShare a Scribd company logo
1 of 26
Download to read offline
<WEB-COMPONENTS>
The component model for the Web 
@revathskumar
ABOUT
Rubyist / JavaScripter
Yeoman team member
Works at @whatznear
Blog at blog.revathskumar.com
Twitter/Github ­ @revathskumar
+RevathSKumar
 
ITS A JOURNEY INTO THE FUTURE
CONSISTS 4 PIECES
Templates
Custom Elements
Shadow DOM
Imports
TEMPLATES
markup intended to be used later
WHAT WE DO NOW?
<scriptid="indexTemplate"type="text/template">
</script>
<tr>
<td><imgsrc="/image/delete.png"/></td>
</tr></p>
WHAT IN FUTURE?
<templateid="indexTemplate">
<tr>
<td><imgsrc="/image/delete.png"/></td>
</tr>
</template>
varholder=document.getElementById('holder');
vartemplate=document.getElementById('indexTemplate');
templateContent=template.content.cloneNode(true);
holder.appendChild(temp);
CONTENTS IN <TEMPLATE>ARE
Parsed but not rendered
images won't be downloaded
Scripts are not processes
until you actually use it.
CAN I USE?
CUSTOM ELEMENTS
new type of DOM elements which can be defined by authors.
HOW TO DEFINE ONE?
document.registerElement
varp=Object.create(HTMLButtonElement.prototype);
varmyBtn=document.registerElement('my-btn',{
extends:'button',prototype:p
});
METHODS
varp=Object.create(HTMLButtonElement.prototype);
p.someMethod=function(){
//blahblah
}
varmyBtn=document.registerElement('my-btn',{
extends:'button',prototype:p
});
LIFECYCLE CALLBACKS
createdCallback ­­­> after created
attachedCallback ­­­> after inserted to document
detachedCallback ­­­> after removed from document
attributeChangedCallback ­­­> when an attribute added /
removed / changed
USING IN MARKUP
If using existsing tag
<buttonis='my-btn'></button>
If not related to any existing tag
<my-btn></my-btn>
EXTENDING
varp=Object.create(HTMLButtonElement.prototype);
varmyBtn=document.registerElement('my-btn',{
extends:'button',prototype:p
});
varmb=newmyBtn();
varanotherBtn=document.registerElement('another-btn',{
prototype:mb
});
SHADOW DOM
adjunct tree of DOM nodes
FEATURES
can be associated with an element, but do not appear as
child nodes
subtrees form their own scope
contains IDs and styles that overlap with IDs and styles in the
document
separate from the document
CAN I USE?
SHADOW HOST
An element with shadow DOM
Shadow DOM can be applied to an element by
createShadowRoot
the content of the shadow DOM is rendered instead the
element's children
INSERTION POINTS
host's children are displayed at the insertion point
use a element to specify insertion point.
does not change where the elements appear in DOM
"select" attribute lets you choose which children appear at
which insertion point
let you reordered or selectively omit rendering children
<!--document-->
<divid="news">
<h1>Gooddayforkittens</h1>
<divclass="breaking">Kittenrescuedfromtree</div>
<div>Areakitten"adorable"&mdash;owner</div>
<divclass="breaking">Jiggledpieceofyarnderailskittenkongress</div>
</div>
<!--#news'shadow-->
<templateid="t">
<contentselect="h1"></content>
<divid="ticker">
<contentid="stories"></content>
</div>
</template>
//SetupshadowDOM
varnews=document.querySelector('#news');
varr=news.createShadowRoot();
vart=document.querySelector('#t');
r.appendChild(t.content.cloneNode(true));
<divid="news">
<h1>Gooddayforkittens</h1>
<divid="ticker">
<divclass="breaking">Kittenrescuedfromtree</div>
<div>Areakitten"adorable"&mdash;owner</div>
<divclass="breaking">Jiggledpieceofyarnderailskittenkongress</div>
</div>
</div>
CAN I USE?
IMPORTS
Load custom elements from external files
Load using tag
<linkrel="import"href="goodies.html">
DOM available to script through the import property
THANK YOU.

More Related Content

What's hot

What's hot (19)

BOOM Performance
BOOM PerformanceBOOM Performance
BOOM Performance
 
Web Components: What, Why, How, and When
Web Components: What, Why, How, and WhenWeb Components: What, Why, How, and When
Web Components: What, Why, How, and When
 
Spa, isomorphic and back to the server our journey with js @ frontend con po...
Spa, isomorphic and back to the server  our journey with js @ frontend con po...Spa, isomorphic and back to the server  our journey with js @ frontend con po...
Spa, isomorphic and back to the server our journey with js @ frontend con po...
 
Experience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - HighlightsExperience Manager 6 Developer Features - Highlights
Experience Manager 6 Developer Features - Highlights
 
Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...
Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...
Bootstrap 3 - Sleek, intuitive, and powerful mobile first front-end framework...
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
Fronteers 2012 - Lessons learned from building a SAAS app
Fronteers 2012 - Lessons learned from building a SAAS appFronteers 2012 - Lessons learned from building a SAAS app
Fronteers 2012 - Lessons learned from building a SAAS app
 
Fronted From Scratch - Supercharge Magento page speed
Fronted From Scratch - Supercharge Magento page speedFronted From Scratch - Supercharge Magento page speed
Fronted From Scratch - Supercharge Magento page speed
 
Real-World AJAX with ASP.NET
Real-World AJAX with ASP.NETReal-World AJAX with ASP.NET
Real-World AJAX with ASP.NET
 
Don't Over-React - just use Vue!
Don't Over-React - just use Vue!Don't Over-React - just use Vue!
Don't Over-React - just use Vue!
 
MVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web ApplicationsMVC Frameworks for building PHP Web Applications
MVC Frameworks for building PHP Web Applications
 
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Hello world
Hello worldHello world
Hello world
 
Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4Upstate CSCI 450 WebDev Chapter 4
Upstate CSCI 450 WebDev Chapter 4
 
Bootstrap Introduction
Bootstrap IntroductionBootstrap Introduction
Bootstrap Introduction
 
Joomla wireframing Template - Joomladay Netherlands 2014 #jd14nl
Joomla wireframing Template - Joomladay Netherlands 2014 #jd14nlJoomla wireframing Template - Joomladay Netherlands 2014 #jd14nl
Joomla wireframing Template - Joomladay Netherlands 2014 #jd14nl
 
Web&java. jsp
Web&java. jspWeb&java. jsp
Web&java. jsp
 
Web Component
Web ComponentWeb Component
Web Component
 

Viewers also liked

Nom.Arte (P)
Nom.Arte (P)Nom.Arte (P)
Nom.Arte (P)
NomArte
 
Baby powerpoint 2
Baby powerpoint 2Baby powerpoint 2
Baby powerpoint 2
Blakefred
 
Modern frontend workflow
Modern frontend workflowModern frontend workflow
Modern frontend workflow
Revath S Kumar
 
Sample Customer Pitch Deck
Sample Customer Pitch DeckSample Customer Pitch Deck
Sample Customer Pitch Deck
kylec2000
 

Viewers also liked (18)

Rack
RackRack
Rack
 
Setup nodejs
Setup nodejsSetup nodejs
Setup nodejs
 
Side projects : why it fails
Side projects : why it failsSide projects : why it fails
Side projects : why it fails
 
Katl aglaera
Katl aglaeraKatl aglaera
Katl aglaera
 
프레젠테이션1
프레젠테이션1프레젠테이션1
프레젠테이션1
 
Nom.Arte (P)
Nom.Arte (P)Nom.Arte (P)
Nom.Arte (P)
 
Baby powerpoint 2
Baby powerpoint 2Baby powerpoint 2
Baby powerpoint 2
 
gulp
gulpgulp
gulp
 
VCR
VCRVCR
VCR
 
Consultoria
ConsultoriaConsultoria
Consultoria
 
Promises in JavaScript
Promises in JavaScriptPromises in JavaScript
Promises in JavaScript
 
MTL Versus Free
MTL Versus FreeMTL Versus Free
MTL Versus Free
 
Modern frontend workflow
Modern frontend workflowModern frontend workflow
Modern frontend workflow
 
Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02Prateek dayal backbonerails-110528024926-phpapp02
Prateek dayal backbonerails-110528024926-phpapp02
 
My webapp workflow
My webapp workflowMy webapp workflow
My webapp workflow
 
Streams for (Co)Free!
Streams for (Co)Free!Streams for (Co)Free!
Streams for (Co)Free!
 
Sample Customer Pitch Deck
Sample Customer Pitch DeckSample Customer Pitch Deck
Sample Customer Pitch Deck
 
Unit testing with mocha
Unit testing with mochaUnit testing with mocha
Unit testing with mocha
 

Similar to Web components

Caracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmCaracteristicas Basicas De Htlm
Caracteristicas Basicas De Htlm
Maria S Rivera
 
Templates
TemplatesTemplates
Templates
soon
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
sblackman
 
Polymer
Polymer Polymer
Polymer
jskvara
 

Similar to Web components (20)

Introduction to web components
Introduction to web componentsIntroduction to web components
Introduction to web components
 
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
Why You Should be Using Web Components Right Now. And How. ForwardJS July 2015
 
Caracteristicas Basicas De Htlm
Caracteristicas Basicas De HtlmCaracteristicas Basicas De Htlm
Caracteristicas Basicas De Htlm
 
The Complementarity of React and Web Components
The Complementarity of React and Web ComponentsThe Complementarity of React and Web Components
The Complementarity of React and Web Components
 
Up & Running with Polymer
Up & Running with PolymerUp & Running with Polymer
Up & Running with Polymer
 
The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014The Structure of Web Code: A Case For Polymer, November 1, 2014
The Structure of Web Code: A Case For Polymer, November 1, 2014
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Templates
TemplatesTemplates
Templates
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
 
WebComponents LT at AQ
WebComponents LT at AQWebComponents LT at AQ
WebComponents LT at AQ
 
Private slideshow
Private slideshowPrivate slideshow
Private slideshow
 
Polymer
Polymer Polymer
Polymer
 
Create rich web stories with Drupal 8 and paragraphs
Create rich web stories with Drupal 8 and paragraphsCreate rich web stories with Drupal 8 and paragraphs
Create rich web stories with Drupal 8 and paragraphs
 
Polymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web componentsPolymer - pleasant client-side programming with web components
Polymer - pleasant client-side programming with web components
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
Desenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery MobileDesenvolvimento web com jQuery Mobile
Desenvolvimento web com jQuery Mobile
 
Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?Orchard Harvest 2014 - The Future of Widgets?
Orchard Harvest 2014 - The Future of Widgets?
 
Polymer - Lego for the web!
Polymer - Lego for the web!Polymer - Lego for the web!
Polymer - Lego for the web!
 
Why you should be using Web Components. And How - DevWeek 2015
Why you should be using Web Components. And How - DevWeek 2015Why you should be using Web Components. And How - DevWeek 2015
Why you should be using Web Components. And How - DevWeek 2015
 
Polymer and web component
Polymer and web componentPolymer and web component
Polymer and web component
 

Recently uploaded

Recently uploaded (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 

Web components