SlideShare a Scribd company logo
1 of 71
Download to read offline
By @LostInBrittany
Web Components
avec Polymer
Spaniard lost in Brittany, Java developer,
dreamer and all-around geek
● Co-founder of the FinistJUG, GDG Finistère &
BreizhBeans
● Senior Developer at Cityzen Data
http://lostinbrittany.org/
+Horacio.Gonzalez
@LostInBrittany
Horacio Gonzalez
Introduction
Because I love to tell old stories
Warning : I’m a web developer
● And when I tell stories, I do it from the webdev POV
So please, thick-client devs,
allow me some oversimplifications
Image : TylkoMrok.pl
At the beginning we had the thick client
● Widget : basic building blocks of your UI
○ Encapsulation
○ Reutilisation
In thick client you create your UI by widget assembling
Image : Wikipedia
Web development was unlike thick-client
● HTML/CSS/JS didn't support widgets
○ Pages were the building blocks
Web apps we're page oriented
Image : IBM
GWT gave back widgets to web devs
● GWT uses a thick-client-like development paradigm
○ Widgets, properties, events
GWT web apps are widget oriented :
Single-page apps
Image : GWT Mail sample app
Single-page apps are a current trend
● From UX POV single-page apps are richer
○ But making them without widgets is painful
HTML/CSS/JS needed a widget standard
Image : Ken Schultz comedy juggler
Web Components
Reinventing the wheel...
and this time making it round
Web Components : a W3C standard
● Web Components standard is being worked at W3C
○ We all know what this means
■ Clue : HTML5
They will work for years, bickering and fighting
Browsers and devs will use the WiP document
Example : the Google+ button
● If you want to place a Google+ button in your page
Example : the Google+ button
● And what I would like is simple
Example : the Google+ button
● To be fair, Google already makes it simpler
● They create directives with JS to emulate components
○ AngularJS approach
○ Respecting the spirit of the future standard
○ Working in current browsers
Another example : the RIB
● If you're French, you know what a RIB is
○ A banking account identification number
● To show a RIB in HTML:
○ All styling & surface control must be done elsewhere by CSS and JS
● What I would like
○ A semantic tag
○ With encapsulated styling and surface controlling
But we already can do that!
● In most modern frameworks we can already do
components, in a way or another
○ And all those ways are different!
○ Using different JavaScript libraries
○ Almost no component sharing between frameworks
● W3C's works aim to make a standard way
○ Supported natively by all browsers
○ Allowing for component reuse
The 5 pillars of the Web Components
● Templates
● Shadow DOM
● Custom Elements
● Decorators
● Imports
Templates
The clone wars
Image : Instructables
Templates
● A reusable model
○ Contains markup intended to be used later
○ Create the elements in page by cloning the template
Templates before
● How did we do templating before
○ Using or
○ Putting it inside a
■ Type unknown to browser, it isn't interpreted
■ Markup easily recovered via .innerHTML and reused
■ Approach used by many template engines
● Uniformising those approach with a new tag
● Content inside the tag is parsed but not interpreted
○ HTML not shown
○ Resources are not loaded
○ Scripts not executed
The tag
Template instantiation
● Using JavaScript
Shadow DOM
Join the shadowy side,
young padawan
Image: Springfield Punx
Encapsulation
● Each component should have
○ Public interface
○ Private inner code
● When using a component
○ You manipulate the interface only
○ You don't need to know anything about inner code
○ No conflict between inner code and outside code
Encapsulation before Shadow DOM
●
Image : Star Trek the Next Generation
Browsers already use encapsulation
● Considerer this simple slider
○ How is is done inside?
■ With HTML, CSS and JS!
○ It has a movable element, I can recover it's position
■ Why cannot see it in DOM tree?
● Browsers hide DOM sub-trees for standard components
○ They have a public interface and hidden inner code
That's Shadow DOM!
Image: Springfield Punx
My name is DOM, Shadow DOM
● Shadow DOM: ability of the browser to
○ Include a DOM subtree into the rendering
○ But not into the main document DOM tree
● In Chome you can see the Shadow DOM
○ By activating the option in Inspector
Looking into the Shadow
● For the slider :
Shadow DOM is already here
● Browser use it everyday...
○ For their inner needs
○ Not exposed to developers
● Web Components makes Shadow DOM available
○ You can use it for your own components
Image: Springfield Punx
Using Shadow DOM
● There is a host element
○ A normal element in DOM tree
● A shadow root is associated to the host
○ Using the createShadowRoot method
○ The shadow root is the root of the hidden DOM tree
Image: W3C
Using Shadow DOM
● Quick and dirty Shadow DOM
○ DOM tree only shows
○ Rendered HTML shows
○ Markup in is ugly
Using Shadow DOM
● Shadow DOM with templates
● HTML elements are compositional
○ You can put a button inside a table
● Shadow DOM elements need to be compositional
○ Insertion points in the Shadow DOM
Separate content from presentation
…
Result :
● More granularity can be added :
Separate content from presentation
…
…
Result :
Why does it work for author?
Invitation model, first match
● CSS defined in the Shadow DOM remains there
● Outside styles don't affect Shadowed content
This is a title
And this is widget title
Widget content here
Shadow DOM et CSS
Shadow DOM et CSS
● Styling the host element : @host
My Button
Shadow DOM et CSS
● Inheriting and resetting styles in Shadow DOM content
○
■ false (default) : properties are inherited
■ true : inheritable properties are reset to initial
○
■ false (default) : author styles aren't applied
■ true: author styles bleed into the content
● widget theming
Shadow DOM et CSS
● Inheritance Cheat Sheet
Image : HTML5 Rocks' Web Components 201
Example
Custom Elements
Elemental mayhem !
Image : The Brick Blogger
Custom elements : the tag
● An element encloses template, lifecycle and behaviour
○ Templates done with tag
● Livecycle defined with 3 callbacks
○ : called after the element is created
○ : called after the element is inserted into a
document
○ : called after the element is removed
Custom elements : the tag
● If an element extends another, instantiation with is keyword
Custom elements : instantiation
● If an element doesn't extends, its name becomes a custom tag
Imports
Because you hate long files
Image : Brikipedia
● Custom elements can be loaded from external files
○ Using the link tag:
○ Only and are interpreted
○ The DOM of this document is available to script
○ Documents are retrieved according to cross-origin policies
Imports
Other interesting bits
Even if outside Web Components
Image : Urban moms
● Provide developers a way to react to changes in DOM
Mutation Observers
● Replace MutationEvents
○ Increased performance
● Observe and notify of mutations to JavaScript objects
○ Properties added, updated, deleted or reconfigurated
Object.observe
● Part of ECMA 6
○ Mutation Observers + Object.observer =
Two-ways databinding!
Data-binding
Can I use?
If not, why are you telling us all this sh*t?
Image : Christoph Hauf
Are we componetized yet?
● New Google project
○ Introduced in Google I/O 2013
○ New type of library for the web
○ Built on top of Web Components
○ Designed to leverage the evolving web platform
● What does it means ?
○ Polymer is comprised of two efforts :
■ A core platform to give Web Component capabilities to
modern browsers
● Shims for all modern browsers
● Shared with Mozilla x-tag project
■ A next-generation web framework built upon this core
platform
● Called the Polymer.
Polymer
Polymer
● Principes:
○ Everything is a component
■ Encapsulation is needed for a component oriented application
○ Extreme pragmatism
■ Boilerplate is bad
■ Anything repetitive should be re-factored into a component
● Handled by Polymer itself or
● Added into the browser platform itself
○ Salt to taste
■ Use as much or as little of the framework as you wish.
● You want polyfills only : load
● You want extra bits : load
○ Polymer elements
○
Polymer
● Platform technologies are already functional
○ You can use it to add templates, shadow DOM, custom elements
and imports to your app
● Lots of examples in the site
Polymer
● X-Tag is a small JavaScript library
○ created and supported by Mozilla
○ that brings Web Components capabilities
○ to all modern browsers.
● Polymer vs X-tags ?
○ Different features and approaches
○ Mozilla and Google are collaborating
■ building the shared polyfills platform
X-Tags
● AngularJS directives allow to create custom elements
○ Similar but different to Web Components
AngularJS
○ First line declares the directive
■ The element name will be
AngularJS
● AngularJS directives allow to create custom elements
○ : HTML string of that the element will be replaced by
○ : (optional) the template HTML inside another file
○ : the linking function
■ After the template has been loaded, this function is called
● to establish the AngularJS scope
● any last-minute effect
○ jQuery animation or other logic
○ Restrict defines the element scope :
E: DOM element with a custom name,
A: DOM elem. with custom attribute,
C: invocation via a class,
M: invocation via a comment,
● Using the custom elements
AngularJS
Polymer today
Because you can already play!
Step-1 : get Polymer
Step-1.2 : define an element
Step-1.3 : load Polymer, import the element
Step-1.4 : enjoy
Step-2 : Add properties/methods
Step-2.2 : enjoy
Step-3 : Declarative two-ways databinding!
Step-3.2 : enjoy
● You can get current version on github
○ Tagged step by step
Work in progress
Conclusion
That's all folks!
Image : dcplanet.fr
You want to know more?
● W3C's Introduction to Web Components
● HTML5 Rocks' Shadow Dom 101
● HTML5 Rocks' Shadow Dom 201: CSS
● Polymer & X-Tags
● MutationObserver & Object.observe
Thank you !

More Related Content

Similar to 2014 03-25 - GDG Nantes - Web Components avec Polymer

ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...Horacio Gonzalez
 
You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)Igalia
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...Horacio Gonzalez
 
Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18Horacio Gonzalez
 
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"Taming Drupal Blocks for Content Editors a.k.a. "Snippets"
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"Brian Hay
 
Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)Mario García
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkAlive Kuo
 
Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausWomen in Technology Poland
 
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ... Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...Andy Maleh
 
Віталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and DrupalВіталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and DrupalLEDC 2016
 
Introduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran SayedIntroduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran SayedImran Sayed
 
OVERVIEW: Chromium Source Tree
OVERVIEW: Chromium Source TreeOVERVIEW: Chromium Source Tree
OVERVIEW: Chromium Source TreeChang W. Doh
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career RoadmapWebStackAcademy
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersYajushi Srivastava
 
Web Components
Web ComponentsWeb Components
Web ComponentsFITC
 
Responsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebResponsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebHarvard Web Working Group
 

Similar to 2014 03-25 - GDG Nantes - Web Components avec Polymer (20)

ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 3/3 - Web Components avec Po...
 
You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)You Can Work on the Web Patform! (GOSIM 2023)
You Can Work on the Web Patform! (GOSIM 2023)
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 3/3 - Web components avec ...
 
Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18Beyond Polymer - JUG Summer Camp - 2015-09-18
Beyond Polymer - JUG Summer Camp - 2015-09-18
 
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"Taming Drupal Blocks for Content Editors a.k.a. "Snippets"
Taming Drupal Blocks for Content Editors a.k.a. "Snippets"
 
Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)Jbake workshop (Greach 2019)
Jbake workshop (Greach 2019)
 
JavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web frameworkJavascriptMVC: Another choice of web framework
JavascriptMVC: Another choice of web framework
 
Architektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan KrausArchitektura html, css i javascript - Jan Kraus
Architektura html, css i javascript - Jan Kraus
 
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ... Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
Montreal.rb 2022-10-05 - Glimmer DSL for SWT - Ruby Desktop Development GUI ...
 
Віталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and DrupalВіталій Бобров — Web components, Polymer and Drupal
Віталій Бобров — Web components, Polymer and Drupal
 
Introduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran SayedIntroduction to Gutenberg- Imran Sayed
Introduction to Gutenberg- Imran Sayed
 
OVERVIEW: Chromium Source Tree
OVERVIEW: Chromium Source TreeOVERVIEW: Chromium Source Tree
OVERVIEW: Chromium Source Tree
 
Front-End Developer's Career Roadmap
Front-End Developer's Career RoadmapFront-End Developer's Career Roadmap
Front-End Developer's Career Roadmap
 
Code-Hub
Code-HubCode-Hub
Code-Hub
 
Polymer Web Framework - Swecha Boot Camp
Polymer Web Framework - Swecha Boot CampPolymer Web Framework - Swecha Boot Camp
Polymer Web Framework - Swecha Boot Camp
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Dhtml sohaib ch
Dhtml sohaib chDhtml sohaib ch
Dhtml sohaib ch
 
Web Components
Web ComponentsWeb Components
Web Components
 
Responsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebResponsive Design: Building for a Modern Web
Responsive Design: Building for a Modern Web
 
Dust.js
Dust.jsDust.js
Dust.js
 

More from Horacio Gonzalez

Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Horacio Gonzalez
 
But there is no web component for that - Web Components Remote Conference - 2...
But there is no web component for that - Web Components Remote Conference - 2...But there is no web component for that - Web Components Remote Conference - 2...
But there is no web component for that - Web Components Remote Conference - 2...Horacio Gonzalez
 
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
 Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27 Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27Horacio Gonzalez
 
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...Horacio Gonzalez
 
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSHoracio Gonzalez
 
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09Horacio Gonzalez
 
Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09Horacio Gonzalez
 
Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20Horacio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptHoracio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...Horacio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLHoracio Gonzalez
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JSENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JSHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptHoracio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...Horacio Gonzalez
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSHoracio Gonzalez
 
Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16 Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16 Horacio Gonzalez
 
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...Horacio Gonzalez
 
Bootcamp d'Initiation à Android - 2013/11/30 - Live coding : Hello world!
Bootcamp d'Initiation à Android  - 2013/11/30 - Live coding :   Hello world!Bootcamp d'Initiation à Android  - 2013/11/30 - Live coding :   Hello world!
Bootcamp d'Initiation à Android - 2013/11/30 - Live coding : Hello world!Horacio Gonzalez
 
Bootcamp d'Initiation à Android - 2013/11/30
Bootcamp d'Initiation à Android  - 2013/11/30Bootcamp d'Initiation à Android  - 2013/11/30
Bootcamp d'Initiation à Android - 2013/11/30Horacio Gonzalez
 

More from Horacio Gonzalez (20)

Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
Il n'y a pas que Polymer dans la vie… - RennesJS - 2017-06-27
 
But there is no web component for that - Web Components Remote Conference - 2...
But there is no web component for that - Web Components Remote Conference - 2...But there is no web component for that - Web Components Remote Conference - 2...
But there is no web component for that - Web Components Remote Conference - 2...
 
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
 Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27 Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
Mixité dans le monde des WebComponents - DevFest Toulouse - 2017-09-27
 
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 2/3 - HTML5, CSS3, Twitter B...
 
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2016 2017 - CAI Web S02E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
 
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
Battle of Frameworks: Polymer - Meetup Paris Web Components - 2016-09
 
Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09Mixing Web Components - Best of Web Paris - 2016 06-09
Mixing Web Components - Best of Web Paris - 2016 06-09
 
Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20Polymer in the real life - Devoxx France - 2016 04-20
Polymer in the real life - Devoxx France - 2016 04-20
 
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScriptENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
ENIB 2015 2016 - CAI Web S02E03- Forge JS 1/4 - La forge JavaScript
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 2/3 - HTML5 / CSS3 / Twitter...
 
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQLENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
ENIB 2015 2016 - CAI Web S02E03 - Forge JS 2/4 - MongoDB and NoSQL
 
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JSENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
ENIB 2015 2016 - CAI Web S02E01- Côté Navigateur 1/3 - HTTP, HTML, CSS JS
 
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQLENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
ENIB 2015-2016 - CAI Web - S01E01- MongoDB and NoSQL
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 2/3 - HTML5, CSS3, Twitte...
 
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JSENIB 2015-2016 - CAI Web -  S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
ENIB 2015-2016 - CAI Web - S01E01- Côté navigateur 1/3 - HTTP, HTML, CSS, JS
 
Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16 Mixing Web Components - Paris Web Components - 2015 09-16
Mixing Web Components - Paris Web Components - 2015 09-16
 
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
Steven Le Roux - Kafka et Storm au service de la lutte antiDDoS à OVH - Soiré...
 
Bootcamp d'Initiation à Android - 2013/11/30 - Live coding : Hello world!
Bootcamp d'Initiation à Android  - 2013/11/30 - Live coding :   Hello world!Bootcamp d'Initiation à Android  - 2013/11/30 - Live coding :   Hello world!
Bootcamp d'Initiation à Android - 2013/11/30 - Live coding : Hello world!
 
Bootcamp d'Initiation à Android - 2013/11/30
Bootcamp d'Initiation à Android  - 2013/11/30Bootcamp d'Initiation à Android  - 2013/11/30
Bootcamp d'Initiation à Android - 2013/11/30
 

Recently uploaded

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 

2014 03-25 - GDG Nantes - Web Components avec Polymer

  • 2. Spaniard lost in Brittany, Java developer, dreamer and all-around geek ● Co-founder of the FinistJUG, GDG Finistère & BreizhBeans ● Senior Developer at Cityzen Data http://lostinbrittany.org/ +Horacio.Gonzalez @LostInBrittany Horacio Gonzalez
  • 3. Introduction Because I love to tell old stories
  • 4. Warning : I’m a web developer ● And when I tell stories, I do it from the webdev POV So please, thick-client devs, allow me some oversimplifications Image : TylkoMrok.pl
  • 5. At the beginning we had the thick client ● Widget : basic building blocks of your UI ○ Encapsulation ○ Reutilisation In thick client you create your UI by widget assembling Image : Wikipedia
  • 6. Web development was unlike thick-client ● HTML/CSS/JS didn't support widgets ○ Pages were the building blocks Web apps we're page oriented Image : IBM
  • 7. GWT gave back widgets to web devs ● GWT uses a thick-client-like development paradigm ○ Widgets, properties, events GWT web apps are widget oriented : Single-page apps Image : GWT Mail sample app
  • 8. Single-page apps are a current trend ● From UX POV single-page apps are richer ○ But making them without widgets is painful HTML/CSS/JS needed a widget standard Image : Ken Schultz comedy juggler
  • 9. Web Components Reinventing the wheel... and this time making it round
  • 10. Web Components : a W3C standard ● Web Components standard is being worked at W3C ○ We all know what this means ■ Clue : HTML5 They will work for years, bickering and fighting Browsers and devs will use the WiP document
  • 11. Example : the Google+ button ● If you want to place a Google+ button in your page
  • 12. Example : the Google+ button ● And what I would like is simple
  • 13. Example : the Google+ button ● To be fair, Google already makes it simpler ● They create directives with JS to emulate components ○ AngularJS approach ○ Respecting the spirit of the future standard ○ Working in current browsers
  • 14. Another example : the RIB ● If you're French, you know what a RIB is ○ A banking account identification number ● To show a RIB in HTML: ○ All styling & surface control must be done elsewhere by CSS and JS ● What I would like ○ A semantic tag ○ With encapsulated styling and surface controlling
  • 15. But we already can do that! ● In most modern frameworks we can already do components, in a way or another ○ And all those ways are different! ○ Using different JavaScript libraries ○ Almost no component sharing between frameworks ● W3C's works aim to make a standard way ○ Supported natively by all browsers ○ Allowing for component reuse
  • 16. The 5 pillars of the Web Components ● Templates ● Shadow DOM ● Custom Elements ● Decorators ● Imports
  • 18. Templates ● A reusable model ○ Contains markup intended to be used later ○ Create the elements in page by cloning the template
  • 19. Templates before ● How did we do templating before ○ Using or ○ Putting it inside a ■ Type unknown to browser, it isn't interpreted ■ Markup easily recovered via .innerHTML and reused ■ Approach used by many template engines
  • 20. ● Uniformising those approach with a new tag ● Content inside the tag is parsed but not interpreted ○ HTML not shown ○ Resources are not loaded ○ Scripts not executed The tag
  • 22. Shadow DOM Join the shadowy side, young padawan Image: Springfield Punx
  • 23. Encapsulation ● Each component should have ○ Public interface ○ Private inner code ● When using a component ○ You manipulate the interface only ○ You don't need to know anything about inner code ○ No conflict between inner code and outside code
  • 24. Encapsulation before Shadow DOM ● Image : Star Trek the Next Generation
  • 25. Browsers already use encapsulation ● Considerer this simple slider ○ How is is done inside? ■ With HTML, CSS and JS! ○ It has a movable element, I can recover it's position ■ Why cannot see it in DOM tree? ● Browsers hide DOM sub-trees for standard components ○ They have a public interface and hidden inner code That's Shadow DOM! Image: Springfield Punx
  • 26. My name is DOM, Shadow DOM ● Shadow DOM: ability of the browser to ○ Include a DOM subtree into the rendering ○ But not into the main document DOM tree ● In Chome you can see the Shadow DOM ○ By activating the option in Inspector
  • 27. Looking into the Shadow ● For the slider :
  • 28. Shadow DOM is already here ● Browser use it everyday... ○ For their inner needs ○ Not exposed to developers ● Web Components makes Shadow DOM available ○ You can use it for your own components Image: Springfield Punx
  • 29. Using Shadow DOM ● There is a host element ○ A normal element in DOM tree ● A shadow root is associated to the host ○ Using the createShadowRoot method ○ The shadow root is the root of the hidden DOM tree Image: W3C
  • 30. Using Shadow DOM ● Quick and dirty Shadow DOM ○ DOM tree only shows ○ Rendered HTML shows ○ Markup in is ugly
  • 31. Using Shadow DOM ● Shadow DOM with templates
  • 32. ● HTML elements are compositional ○ You can put a button inside a table ● Shadow DOM elements need to be compositional ○ Insertion points in the Shadow DOM Separate content from presentation … Result :
  • 33. ● More granularity can be added : Separate content from presentation … … Result : Why does it work for author? Invitation model, first match
  • 34. ● CSS defined in the Shadow DOM remains there ● Outside styles don't affect Shadowed content This is a title And this is widget title Widget content here Shadow DOM et CSS
  • 35. Shadow DOM et CSS ● Styling the host element : @host My Button
  • 36. Shadow DOM et CSS ● Inheriting and resetting styles in Shadow DOM content ○ ■ false (default) : properties are inherited ■ true : inheritable properties are reset to initial ○ ■ false (default) : author styles aren't applied ■ true: author styles bleed into the content ● widget theming
  • 37. Shadow DOM et CSS ● Inheritance Cheat Sheet Image : HTML5 Rocks' Web Components 201
  • 39. Custom Elements Elemental mayhem ! Image : The Brick Blogger
  • 40. Custom elements : the tag ● An element encloses template, lifecycle and behaviour ○ Templates done with tag
  • 41. ● Livecycle defined with 3 callbacks ○ : called after the element is created ○ : called after the element is inserted into a document ○ : called after the element is removed Custom elements : the tag
  • 42. ● If an element extends another, instantiation with is keyword Custom elements : instantiation ● If an element doesn't extends, its name becomes a custom tag
  • 43. Imports Because you hate long files Image : Brikipedia
  • 44. ● Custom elements can be loaded from external files ○ Using the link tag: ○ Only and are interpreted ○ The DOM of this document is available to script ○ Documents are retrieved according to cross-origin policies Imports
  • 45. Other interesting bits Even if outside Web Components Image : Urban moms
  • 46. ● Provide developers a way to react to changes in DOM Mutation Observers ● Replace MutationEvents ○ Increased performance
  • 47. ● Observe and notify of mutations to JavaScript objects ○ Properties added, updated, deleted or reconfigurated Object.observe ● Part of ECMA 6
  • 48. ○ Mutation Observers + Object.observer = Two-ways databinding! Data-binding
  • 49. Can I use? If not, why are you telling us all this sh*t? Image : Christoph Hauf
  • 51. ● New Google project ○ Introduced in Google I/O 2013 ○ New type of library for the web ○ Built on top of Web Components ○ Designed to leverage the evolving web platform ● What does it means ? ○ Polymer is comprised of two efforts : ■ A core platform to give Web Component capabilities to modern browsers ● Shims for all modern browsers ● Shared with Mozilla x-tag project ■ A next-generation web framework built upon this core platform ● Called the Polymer. Polymer
  • 53. ● Principes: ○ Everything is a component ■ Encapsulation is needed for a component oriented application ○ Extreme pragmatism ■ Boilerplate is bad ■ Anything repetitive should be re-factored into a component ● Handled by Polymer itself or ● Added into the browser platform itself ○ Salt to taste ■ Use as much or as little of the framework as you wish. ● You want polyfills only : load ● You want extra bits : load ○ Polymer elements ○ Polymer
  • 54. ● Platform technologies are already functional ○ You can use it to add templates, shadow DOM, custom elements and imports to your app ● Lots of examples in the site Polymer
  • 55. ● X-Tag is a small JavaScript library ○ created and supported by Mozilla ○ that brings Web Components capabilities ○ to all modern browsers. ● Polymer vs X-tags ? ○ Different features and approaches ○ Mozilla and Google are collaborating ■ building the shared polyfills platform X-Tags
  • 56. ● AngularJS directives allow to create custom elements ○ Similar but different to Web Components AngularJS ○ First line declares the directive ■ The element name will be
  • 57. AngularJS ● AngularJS directives allow to create custom elements ○ : HTML string of that the element will be replaced by ○ : (optional) the template HTML inside another file ○ : the linking function ■ After the template has been loaded, this function is called ● to establish the AngularJS scope ● any last-minute effect ○ jQuery animation or other logic ○ Restrict defines the element scope : E: DOM element with a custom name, A: DOM elem. with custom attribute, C: invocation via a class, M: invocation via a comment,
  • 58. ● Using the custom elements AngularJS
  • 59. Polymer today Because you can already play!
  • 60. Step-1 : get Polymer
  • 61. Step-1.2 : define an element
  • 62. Step-1.3 : load Polymer, import the element
  • 64. Step-2 : Add properties/methods
  • 66. Step-3 : Declarative two-ways databinding!
  • 68. ● You can get current version on github ○ Tagged step by step Work in progress
  • 70. You want to know more? ● W3C's Introduction to Web Components ● HTML5 Rocks' Shadow Dom 101 ● HTML5 Rocks' Shadow Dom 201: CSS ● Polymer & X-Tags ● MutationObserver & Object.observe