Web Components are touted as the future of front-end web development. In this talk you’ll learn what Web Components are, how to use them and the state of native support in web browsers. Finally I’ll demonstrate what your options are for building componentized web apps right now using AngularJS, Ember, Knockout, React, Polymer etc. And why Web Components probably are the future of front-end web development.
65. Get & use document from the currentScript
( function( currentScript ) {
var importDoc = currentScript.ownerDocument;
TeamPusherPrototype.createdCallback = function() {
var content = importDoc.querySelector( '#team-pusher-tmpl' ).content;
// ...
};
} )( document._currentScript || document.currentScript );
65 / 157
66. importNode and NOT cloneNode for Template
// Note: use ownerDoc
var content = ownerDoc.querySelector( '#my-template' );
var clone = ownerDoc.importNode( content, true );
66 / 157
67. You can't <link> into the Shadow DOM
<template>
<link rel="stylesheet" href="path/to/style.css" />
</template>
67 / 157
71. The State of Shadow DOM
<content select="tag" />
Declarative element content placement
71 / 157
72. The State of Shadow DOM
<content select="tag" />
Declarative element content placement
element.createShadowRoot({ mode:
'closed' });
protecting shadowRoot
72 / 157
73. The State of Shadow DOM
<content select="tag" />
Declarative element content placement
element.createShadowRoot({ mode:
'closed' });
protecting shadowRoot
.foo >>> div { color: red }
Shadow piercing combinators
...
73 / 157
76. Essential "State of" Reading
Wilson Page - The State of Web Components
Microsoft Edge Team - Bringing componentization to the web: An
overview of Web Components
76 / 157
79. Apple's updated feedback on Custom Elements and Shadow DOM
From: Maciej Stachowiak <mjs@apple.com>
Date: Mon, 20 Jul 2015 18:17:24 -0700
Message-id: <E9841AA1-9255-4324-946E-E785B15DAE93@apple.com>
To: public-webapps <public-webapps@w3.org>
A while back we sent a consolidated pile of feedback on the Web Components family of specs. In preparation for tomorrow's F2F, here is an update on
our positions. We've also changed the bugzilla links to point to relevant github issues instead.
We're only covering Custom Elements (the main expected topic), and also Shadow DOM (in case that gets discussed too).
I. ==== Custom Elements ====
A. ES6 classes / Upgrade / Synchronous Constructors
1. In general, we support the "synchronous constructors" approach to the "prototype swizzling" approach, as the lesser evil. While
tricky to implement correctly, it makes a lot more sense and fits more naturally into the language. We are willing to do the work to make it
feasible.
2. Custom elements should support initialization using an ES6 class constructo instead of a separate callback.
<https://github.com/w3c/webcomponents/issues/139 <https://www.w3.org/Bugs/Public/show_bug.cgi?id=28541>>
3. We don’t think upgrading should be supported. The tradeoffs of different options have been much-discussed.
<https://github.com/w3c/webcomponents/issues/134 <https://www.w3.org/Bugs/Public/show_bug.cgi?id=28544>>
4. Specifically, we don't really like the "Optional Upgrades, Optional Constructors" proposal (seems like it's the worst of both
worlds in terms of complexity and weirdness) or the "Parser-Created Classes" proposal (not clear how this even solves the problem).
B. Insertion/Removal Callbacks
1. We think the current attached/detached callbacks should be removed. They don’t match core DOM concepts and insert/remove is a
more natural bracket. The primitives should be insertedIntoDocument / removedFromDocument and inserted / removed. If you care about whether your
document is rendered, look at its defaultView property. <https://github.com/w3c/webcomponents/issues/286>
2. We think inserted/removed callbacks should be added, for alignment with DOM. <https://github.com/w3c/webcomponents/issues/222>
C. Inheritance for Built-ins
1. We think support for inheritance from built-in elements (other than HTMLElement/SVGElement) should be omitted from a cross-
browser v1. It raises complex implementation issues. <https://github.com/w3c/webcomponents/issues/133 <https://www.w3.org/Bugs/Public/show_bug.cgi?
id=28547>>
D. Syntactic Sugar / Developer Ergonomics
1. We think it would be useful (perhaps post-v1) to make it simpler to create a custom element that is always instantiated with a
shadow DOM from a template. Right now, this common use case requires script and a template in separate places, and a few lines of confusing
79 / 157
Safari
80. Can I use ? Settingsweb components
4 results found
# Global 67.55%
U.K. 70.69%
IE / Edge Firefox Chrome Safari Opera iOS Safari
*
Opera Mini
* Android
Browser
* Chrome for
Android
8
9
10
11
Edge
31
38
39
40
41
42
31
36
37
39
40
42
43
44
45
46
47
7
7.1
8
9
30
31
32
7.1
8.4
9
8
4.1
4.3
4.4
4.4.4
40 42
HTML templates - LS
Method of declaring a portion of reusable markup that is parsed
but not rendered until cloned.
Current aligned Usage relative Show all
80 / 157
State of Browser Support
84. Christian Heilmann - July 1st, 2015
‘When we asked the very captive and elite
audience of EdgeConf about Web Components,
nobody raised their hand that they are using them
in real products.
84 / 157
85. Componentised Web Apps Now -
questions?
Should native browser support stop us thinking about building componentised
web apps?
85 / 157
86. Componentised Web Apps Now -
questions?
Should native browser support stop us thinking about building componentised
web apps?
No!
86 / 157
87. Componentised Web Apps Now -
questions?
Should native browser support stop us thinking about building componentised
web apps?
No!
Should we be build componentised web apps anyway?
87 / 157
88. Componentised Web Apps Now -
questions?
Should native browser support stop us thinking about building componentised
web apps?
No!
Should we be build componentised web apps anyway?
We're already building web apps out of components right now!
88 / 157
128. Who's Building Componentised Web Apps now?
Angular, Ember, Backbone, Knockout, React, Vue.js, Web Components with Polyfills, Polymer
...
128 / 157
129. Who's Building Componentised Web Apps now?
Angular, Ember, Backbone, Knockout, React, Vue.js, Web Components with Polyfills, Polymer
...
You are!
<ng-avatar service="twitter" username="leggetter" />
vs.
<my-avatar service="twitter" username="leggetter" />
129 / 157
130. Who's Building Componentised Web Apps now?
Angular, Ember, Backbone, Knockout, React, Vue.js, Web Components with Polyfills, Polymer
...
You are!
<ng-avatar service="twitter" username="leggetter" />
vs.
<my-avatar service="twitter" username="leggetter" />
That's the HOW
130 / 157
134. Libraries
Alignment toward Web Components
Angular - Directives
Ember - Components
Knockout - Components
Polymer - build upon Web Components
Angular 2...
134 / 157
135. http://guides.emberjs.com/v1.13.0/components/
‘Ember's implementation of components hews as
closely to the Web Components specification as
possible. Once Custom Elements are widely
available in browsers, you should be able to easily
migrate your Ember components to the W3C
standard and have them be usable by other
frameworks.
135 / 157
137. Have a Strategy
Will libraries update to use Web Components?
Align with Web Components to make migrating easier
Split UI rendering and business logic
137 / 157
139. Dashboard Get Started Design Develop Publish Community WPDev Feedback
Microsoft Edge Developer
Welcome to the Microsoft Edge Developer Suggestion Box!
The Microsoft Edge team is looking for feature requests from the web developer and designer community. Categories
include (but certainly are not limited to) HTML, CSS, JavaScript, Performance, and Developer Tools. If you do not have
a suggestion at this time, you may still cast your vote for the features you would like to see supported!
This feedback will help us with planning and to better understand how web developers and designers are using the
platform. Top standards-based feature requests will also be copied over to http://dev.modern.ie/platform/status/, where
you can track its development status.
Note that this forum is intended for web platform feature suggestions. Related feedback channels:
Microsoft Edge application feedback (or use the Windows Feedback app in Windows Technical Preview)
Microsoft Edge feedback on Windows Phone
For specific bugs, please log an issue on the Connect site
Finally – a few guidelines and notes to keep things running smoothly:
1. Please be sure to search for ideas before entering a new suggestion. This helps to accrue the votes correctly.
2. Please enter a separate suggestion for each idea (avoid entering a suggestion with multiple ideas) and share
some information if possible on the most important scenarios that this enables for you. This helps to keep things
clear as to what people are voting for.
3. The items and rankings on this site are an important input, but do not reflect the final priority list for the Microsoft
Edge engineering team.
4. We will moderate suggestions made in the forum if they do not represent an actual feature request or are
inappropriate.
5. Please do not send any novel or patentable ideas, copyrighted materials, samples or demos which you do not
want to grant a license to Microsoft. See the Terms of Service for more information.
Microsoft Edge Developer
Post a new idea…
All ideas
My feedback
Accessibility 4
CSS 59
Document Object Model (DOM) 7
Extensions 12
F12 Developer Tools 119
Graphics 21
HTML 49
JavaScript 61
Media 14
Miscellaneous 45
Networking 22
Performance 17
Security 1
New and returning users may sign in
Search 139 / 157
3. Demand
140. 4. Encourages good software
development
Component-based Development
140 / 157
142. Encapsulation
Shadow DOM - Style & DOM encapsulation
Does NOT offer JavaScript protection
Hacky Custom Element
leggetter
twitter
Don't click me!
142 / 157
153. Summary
Custom Elements - Awesome
HTML Templates, Shadow DOM, HTML Imports
- Native FTW
You can & are building componentised web
apps now - Align
153 / 157
154. Summary
Custom Elements - Awesome
HTML Templates, Shadow DOM, HTML Imports
- Native FTW
You can & are building componentised web
apps now - Align
Trends & "best practice" ♥ Web Components
154 / 157
155. Summary
Custom Elements - Awesome
HTML Templates, Shadow DOM, HTML Imports
- Native FTW
You can & are building componentised web
apps now - Align
Trends & "best practice" ♥ Web Components
Web Components are the future!
155 / 157
156. Resources
http://webcomponents.org/
https://www.polymer-project.org
Wilson Page - The State of Web Components
Christian Heilmann - Web Components are an Endangered Species
Are we compontentized yet (podcast)
Eric Bidelman's Google IO 2014 talk
Angular Material
Google Material Design
HTML Template Chooser
IE UserVoice forum
Source for these slides
http://pusher.com - easily add realtime messaging to your apps
156 / 157
157. Why you should be using Web Components Now.
And How.
Questions?
leggetter.github.io/web-components-now
PHIL @LEGGETTER
Head of Developer Relations
157 / 157