SlideShare a Scribd company logo
CLUB AJAX
by Mike Wilcox, January 2017
Web Components
and ES6 Classes
JS Frameworks
• Some more mobile friendly than others
• Although hard to say that any of them truly are
• Jeff Atwood complains about poor Ember perf for Discourse
• Isomorphic/Universal Apps using server side rendering
• Creates faster visual content on the page
• But also creates a “valley of death” where the page is no functional
• Virtual DOM can sometimes be effective
• Sometimes effective
• Sometimes not
• On demand loading
• Some frameworks support it, some don’t
Web Components v1
Dojo
Dojo
<div class='createSection' data-dojo-attach-point='createSection'>

<div class='row'>

<div data-dojo-attach-point="filterName"

data-dojo-type="app/components/ui/TextFilter" 

data-dojo-props="fieldLabel:'${messages.filterName}', required:
true”>
Dojo
<div class='field'>

${labelNode}

<div data-dojo-attach-point="textbox" class='fieldWidget'

data-dojo-type="dijit/form/TextBox"

data-dojo-attach-event="onKeyUp: _update"></div>

</div>
define([

'dojo/_base/declare',

'dx/Widget',

'dojo/text!./templates/TextFilter.html',

'dijit/form/TextBox'

], function(declare, Widget, template) {



return declare(Widget, {

templateString: template,

postMixInProperties: function(){ },

postCreate: function(){ },

focus: function(){

this.textbox.focus();

},

_setValueAttr: function(value){

this.textbox.set('value', value);

},



_getValueAttr: function(){

return this.textbox.get('value');

},
Dojo
Ember
Ember
<div class="client-page">



{{side-nav nav=navigation clientId=model.client.id}}
Ember
<div class="nav-items">

{{#each nav as |link|}}

{{#unless (eq link.state "hidden") }}

{{#if (eq link.state "disabled") }}

<div class="side-nav-link {{link.state}}">

<div class="side-nav-title">{{link.title}}</div>

</div>

{{else}}

{{#link-to link.route title=link.title class=link.state}}

<div class="side-nav-link {{link.state}}">

<div class="side-nav-title">{{link.title}}</div>

</div>

{{/link-to}}

{{/if}}

{{/unless}}

{{/each}}

</div>
Ember
import Ember from ‘ember';
import Navigation from '../../mixins/navigation';


export default Ember.Component.extend(Navigation, {

classNames: ['side-nav'],

nav: null,
clientId: ‘NA’,
activeNavigation: Ember.computed('navigation', function () {

let activeNavigationObject = [];

this.get('navigation').forEach((mainItem)=> {

...

});

return activeNavigationObject;

}),


});
Angular 2
Angular
<div [ngBusy]="{busy: busy, message: 'Please wait...'}">

<div *ngIf="settingView">

<my-actions [links]="settingView.actionUrls"></my-actions>

</div>

</div>
Angular
<h4>Actions</h4>

<div class="section">

<a href="{{links[0]}}">Change Your Password</a>

<a href="{{links[1]}}">Change Your Security Questions</a>

<a href="{{links[2]}}">Change other usernames for a Single Sign-
On Experience</a>

</div>
Angular
import { Component, Input, OnInit } from '@angular/core';



@Component({

moduleId: module.id.toString(),

selector: 'my-actions',

templateUrl: 'actions.component.html'

})

export class ActionsComponent implements OnInit {

constructor() { }



@Input()

links: string[] = [];



ngOnInit() { }

}
React
React
import React from 'react';

import { render } from 'react-dom';

import Text from './form-sections/text';

export default class Form extends React.Component {

constructor(props) {

super(props);

}

render() {

return ( 

<ay-form ref="form">

<Text />

</ay-form> 

);

}

}

React
import React from 'react';

import { render } from 'react-dom';

import pure from 'react-addons-pure-render-mixin';



export default class Text extends React.Component {

constructor(props) {

super(props);

this.shouldComponentUpdate = pure.shouldComponentUpdate.bind(this);

}

render() {

return (

<section>

<ay-field type="text" value="" name="where"
placeholder="Where"></ay-field>

</section>

);

}

}
jQuery
React
<div class="jq-picker"></div>

<script>

$.ready(function(){

$(".jq-picker").jqPicker(options);

});

</script>
JS Frameworks + Web Components
• Web Components are “just HTML” so they will work with all of them
• It may require some manual wiring, like using addEventListener
• With plugins, you can make use of framework template functionality
• https://github.com/webcomponents/react-integration
• https://github.com/clubajax/react-inject-change-events
What are they?
Web Components Benefits
• Part of the DOM - lifecycle tools for free!
• Future-proof and cross-browser (web standard) for creating and extending
reusable components.
• Requires no library or framework to get started. Vanilla JS/HTML FTW!
• Provides a familiar programming model. It's just DOM/CSS/HTML.
• Creates a very modular system
• Tightly integrated with the browser's DevTools.
• Leverage existing accessibility features.
Web Components
• Custom Elements
• Shadow DOM
• Templates
• HTML Imports
All four of these items are a WC3 spec, all of which makes up Web Components
Custom Elements
• Define your own element types and functionality
• Provides a standard way to associate JavaScript logic with an
element
• Lifecycle methods
• No confusing context — “this” is the element
• Easy to inspect in debuggers
We could do custom elements with
IE6… the difference is the life cycle
methods
<x-tabs>

<ul>Tab 1</ul>

<ul>Tab 2</ul>

<ul>Tab 3</ul>

</x-tabs>
Shadow DOM
Content can be
“projected” into
provided slots
• Shadow DOM refers to the ability of the browser to include a subtree of
DOM elements into the rendering of a document, but not into the main
document DOM tree.
• CSS style rules are constrained to the shadow tree they were defined in.
• The DOM is also encapsulated. For example,
document.querySelectorAll('div'); will not return any results from a
custom element with Shadow DOM
Templates
• The template element is used to declare fragments of HTML
that can be cloned and inserted in the document by script.
• Contains a DocumentFragment in its
HTMLTemplateElement.content property
HTML Imports
<link rel=“import” href=“./my-bugger.html” />

<link rel=“import” href=“./my-zapper.html” />
• Can import all in one file: JavaScript, HTML, and CSS
• Effectively, an HTML document.
• HTML Imports can be the dependency management system, replacing
AMD or CommonJS
• HTML Imports let you include and reuse HTML documents in other HTML
documents, just as script tags let you include external JavaScript in their
pages.
HTML Imports - CONS
The HTML Import spec does not
have consensus. Mozilla is still
holding out, after two years.
<link rel=“import” href=“./my-bugger.html” />

<link rel=“import” href=“./my-zapper.html” />
• Confusing context when importing templates
• Spec essentially competes with ES modules
• Globals
Can I use…?
Browser Support
• Chrome v54
• WebKit Nightly v18
• Edge has begun prototyping
• Firefox has an open bug
Browser Stats
We need to support old IE because we…
• want to expose our servers to unsupported, insecure browsers.
• like to pay the extra IE development cost (8:25%, 9:10%, 10:5%).
• enjoy tying up QA to spend extra time testing more browser versions
https://www.xfive.co/blog/stop-supporting-ie10-ie9-ie8/
Seriously, management often encourages
the support of old versions because they
are not aware of the cost and risk.
Polyfills
• A polyfill for HTML Custom Elements.
• ShadyDOM provides a shim for ShadowDOM V1. It is less correct but less
intrusive and faster than the ShadowDOM Polyfill.
• ShadyCSS provides a shim for CSS Custom Properties, CSS Mixins with
@apply support, and ShadowDOM V1 style encapsulation with the ShadyDOM
library.
v0 vs v1*
*The differences between the old spec and the recent changes
v0
var proto = Object.create(HTMLElement.prototype);

proto.createdCallback = function() {

// invoked on creation

};

proto.attachedCallback = function() {

// invoked when added to the document

};

proto.detachedCallback = function() {

// invoked when removed from the document

};

proto.attributeChangedCallback = function(attrName, oldVal, newVal) {

// invoked when an attribute is changed

};


var MyComponent = document.registerElement('my-component', {

prototype: proto

});
class MyComponent extends HTMLElement {

static get observedAttributes() {
return ['value', 'disabled'];
}

constructor ( ) {

super();

}

connectedCallback ( ) { }

disconnectedCallback ( ) { }

attributeChangedCallback(attrName, oldVal, newVal) { }

adoptedCallback() { }

}

customElements.define('my-component', MyComponent);
v1
constructor: the element is
created or upgraded
connectedCallback: the
element is inserted into the DOM
disconnectedCallback: the
element is removed from the DOM.
attributeChangedCallback:
an attribute was added, removed,
or updated
adoptedCallback the element
has been moved into a new
document
define: exposes the element
name for use in markup
History
Q: Why did the spec change?
A: The old spec did not work with ES6 classes
Q: Does the new spec work wth ES5?
A: uh, sort of…
Q: Who changed it?
A: Blame Apple's Ryosuke Niwa. He’s made a few changes…
Q: Should I wait to use Web Components until v1 is implemented?
A: No, not any more than you would wait for any other shim-able browser feature
Inheritance
class MyButton extends HTMLButtonElement {

constructor () {

super(...arguments);

}

}

customElements.define('my-button', MyButton, {extends: 'button'});
Extends something other than
HTMLElement
Extra argument when defining
Blocked by Apple.
Use native tag, and extended
tag in “is”
This is what it would look like… if it were implemented.
ES6 Classes
class MyComponent extends HTMLElement {

static something () { return 'something'; }

constructor () {

super();

}

connectedCallback () {

//

}

}
always call super() first in the
constructor. “this” is not established until
after
Commas are forbidden to emphasize that
class definitions are different from object
literals.
Classes are sugar for prototypal inheritance. MyComponent is a function that
inherits from the HTMLElement prototype.
static is similar to:
MyComponent.something = function () {
return ’something’;
}
data properties are not allowed like in objects:
{a: true} (yet)
getters and setters must be used.
super is used as a function in the
constructor, as property references:
super.someMethod();
Custom Element API Considerations
• Sync important properties with attributes
• getters/setters over methods
• Broadcast changes via events
• Use standard properties and event names (“value”, “change”)
• innerHTML — what happens, before and after initialization?
• Appending children
• Use :defined or alternative
• Consider Shadow DOM styling pros and cons
DEMOS
Refs
https://github.com/webcomponents/shadydom
https://github.com/webcomponents/shadycss
https://webkit.org/blog/7027/introducing-custom-elements/
https://github.com/webcomponents/react-integration
https://github.com/clubajax/react-inject-change-events
https://hacks.mozilla.org/2014/12/mozilla-and-web-components/
https://www.polymer-project.org/1.0/blog/2016-12-21-polymer-2.0-update
https://developers.google.com/web/fundamentals/getting-started/primers/customelements?hl=en#historysupport
https://twitter.com/AaronGustafson/status/717028669948977153
https://github.com/w3c/webcomponents/issues/509
CLUB AJAX
Ad

More Related Content

What's hot (20)

[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
Ashlimarie
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
BorisMoore
 
Web Components
Web ComponentsWeb Components
Web Components
Nikolaus Graf
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
FITC
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
Rich Bradshaw
 
HTML5, just another presentation :)
HTML5, just another presentation :)HTML5, just another presentation :)
HTML5, just another presentation :)
François Massart
 
JsViews - Next Generation jQuery Templates
JsViews - Next Generation jQuery TemplatesJsViews - Next Generation jQuery Templates
JsViews - Next Generation jQuery Templates
BorisMoore
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
Mark Rackley
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
Matt Raible
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can build
Monika Piotrowicz
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
Yash Mody
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & Polymer
Erik Isaksen
 
What is jQuery?
What is jQuery?What is jQuery?
What is jQuery?
tina3reese7
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
Dave Artz
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
Andrew Rota
 
HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술
Jeongkyu Shin
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher
Ivano Malavolta
 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Training
ubshreenath
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 
[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS[2015/2016] Require JS and Handlebars JS
[2015/2016] Require JS and Handlebars JS
Ivano Malavolta
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
Ashlimarie
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
BorisMoore
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
FITC
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
Rich Bradshaw
 
HTML5, just another presentation :)
HTML5, just another presentation :)HTML5, just another presentation :)
HTML5, just another presentation :)
François Massart
 
JsViews - Next Generation jQuery Templates
JsViews - Next Generation jQuery TemplatesJsViews - Next Generation jQuery Templates
JsViews - Next Generation jQuery Templates
BorisMoore
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
Mark Rackley
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
Matt Raible
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can build
Monika Piotrowicz
 
Sightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVASightly - AEM6 UI Development using JS and JAVA
Sightly - AEM6 UI Development using JS and JAVA
Yash Mody
 
Levent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & PolymerLevent-Gurses' Introduction to Web Components & Polymer
Levent-Gurses' Introduction to Web Components & Polymer
Erik Isaksen
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
Dave Artz
 
Web Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing CombinationWeb Components + Backbone: a Game-Changing Combination
Web Components + Backbone: a Game-Changing Combination
Andrew Rota
 
HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술
Jeongkyu Shin
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher
Ivano Malavolta
 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Training
ubshreenath
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
Aviran Cohen
 

Similar to Web Components v1 (20)

Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
Luther Baker
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Internet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptxInternet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptx
ssuser92282c
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Nidhi Sharma
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
SPTechCon
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
sapientindia
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointSPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
Mark Rackley
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
Jasper Moelker
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
Ioan Eugen Stan
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Roy de Kleijn
 
ReactJS.ppt
ReactJS.pptReactJS.ppt
ReactJS.ppt
MOMEKEMKUEFOUETDUREL
 
Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
cherukumilli2
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
Luther Baker
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
GDSC UofT Mississauga
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
Eric Palakovich Carr
 
Internet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptxInternet protocol second unit IIPPT.pptx
Internet protocol second unit IIPPT.pptx
ssuser92282c
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
Gavin Roy
 
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...Lightning web components - Introduction, component Lifecycle, Events, decorat...
Lightning web components - Introduction, component Lifecycle, Events, decorat...
Nidhi Sharma
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
Advanced SharePoint 2010 and 2013 Web Part Development by Rob Windsor - SPTec...
SPTechCon
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
sapientindia
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
toddbr
 
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePointSPTechCon Boston 2015 - Utilizing jQuery in SharePoint
SPTechCon Boston 2015 - Utilizing jQuery in SharePoint
Mark Rackley
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
Jasper Moelker
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
Ioan Eugen Stan
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
Gil Fink
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Roy de Kleijn
 
Ad

More from Mike Wilcox (20)

Accessibility for Fun and Profit
Accessibility for Fun and ProfitAccessibility for Fun and Profit
Accessibility for Fun and Profit
Mike Wilcox
 
WTF R PWAs?
WTF R PWAs?WTF R PWAs?
WTF R PWAs?
Mike Wilcox
 
Advanced React
Advanced ReactAdvanced React
Advanced React
Mike Wilcox
 
Webpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itWebpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need it
Mike Wilcox
 
Dangerous CSS
Dangerous CSSDangerous CSS
Dangerous CSS
Mike Wilcox
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
Mike Wilcox
 
Model View Madness
Model View MadnessModel View Madness
Model View Madness
Mike Wilcox
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it Right
Mike Wilcox
 
The Great Semicolon Debate
The Great Semicolon DebateThe Great Semicolon Debate
The Great Semicolon Debate
Mike Wilcox
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and How
Mike Wilcox
 
Dojo & HTML5
Dojo & HTML5Dojo & HTML5
Dojo & HTML5
Mike Wilcox
 
Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-Designers
Mike Wilcox
 
Why You Need a Front End Developer
Why You Need a Front End DeveloperWhy You Need a Front End Developer
Why You Need a Front End Developer
Mike Wilcox
 
A Conversation About REST
A Conversation About RESTA Conversation About REST
A Conversation About REST
Mike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
Mike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
Mike Wilcox
 
How to get a Job as a Front End Developer
How to get a Job as a Front End DeveloperHow to get a Job as a Front End Developer
How to get a Job as a Front End Developer
Mike Wilcox
 
The History of HTML5
The History of HTML5The History of HTML5
The History of HTML5
Mike Wilcox
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
Mike Wilcox
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
Mike Wilcox
 
Accessibility for Fun and Profit
Accessibility for Fun and ProfitAccessibility for Fun and Profit
Accessibility for Fun and Profit
Mike Wilcox
 
Webpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itWebpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need it
Mike Wilcox
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
Mike Wilcox
 
Model View Madness
Model View MadnessModel View Madness
Model View Madness
Mike Wilcox
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it Right
Mike Wilcox
 
The Great Semicolon Debate
The Great Semicolon DebateThe Great Semicolon Debate
The Great Semicolon Debate
Mike Wilcox
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and How
Mike Wilcox
 
Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-Designers
Mike Wilcox
 
Why You Need a Front End Developer
Why You Need a Front End DeveloperWhy You Need a Front End Developer
Why You Need a Front End Developer
Mike Wilcox
 
A Conversation About REST
A Conversation About RESTA Conversation About REST
A Conversation About REST
Mike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
Mike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
Mike Wilcox
 
How to get a Job as a Front End Developer
How to get a Job as a Front End DeveloperHow to get a Job as a Front End Developer
How to get a Job as a Front End Developer
Mike Wilcox
 
The History of HTML5
The History of HTML5The History of HTML5
The History of HTML5
Mike Wilcox
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
Mike Wilcox
 
Ad

Recently uploaded (20)

Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Salesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docxSalesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docx
José Enrique López Rivera
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
Hands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordDataHands On: Create a Lightning Aura Component with force:RecordData
Hands On: Create a Lightning Aura Component with force:RecordData
Lynda Kane
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...What is Model Context Protocol(MCP) - The new technology for communication bw...
What is Model Context Protocol(MCP) - The new technology for communication bw...
Vishnu Singh Chundawat
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Salesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docxSalesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docx
José Enrique López Rivera
 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
 
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Enhancing ICU Intelligence: How Our Functional Testing Enabled a Healthcare I...
Impelsys Inc.
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical DebtBuckeye Dreamin 2024: Assessing and Resolving Technical Debt
Buckeye Dreamin 2024: Assessing and Resolving Technical Debt
Lynda Kane
 
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxSpecial Meetup Edition - TDX Bengaluru Meetup #52.pptx
Special Meetup Edition - TDX Bengaluru Meetup #52.pptx
shyamraj55
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.Network Security. Different aspects of Network Security.
Network Security. Different aspects of Network Security.
gregtap1
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 

Web Components v1

  • 2. by Mike Wilcox, January 2017 Web Components and ES6 Classes
  • 3. JS Frameworks • Some more mobile friendly than others • Although hard to say that any of them truly are • Jeff Atwood complains about poor Ember perf for Discourse • Isomorphic/Universal Apps using server side rendering • Creates faster visual content on the page • But also creates a “valley of death” where the page is no functional • Virtual DOM can sometimes be effective • Sometimes effective • Sometimes not • On demand loading • Some frameworks support it, some don’t
  • 6. Dojo <div class='createSection' data-dojo-attach-point='createSection'>
 <div class='row'>
 <div data-dojo-attach-point="filterName"
 data-dojo-type="app/components/ui/TextFilter" 
 data-dojo-props="fieldLabel:'${messages.filterName}', required: true”>
  • 7. Dojo <div class='field'>
 ${labelNode}
 <div data-dojo-attach-point="textbox" class='fieldWidget'
 data-dojo-type="dijit/form/TextBox"
 data-dojo-attach-event="onKeyUp: _update"></div>
 </div>
  • 8. define([
 'dojo/_base/declare',
 'dx/Widget',
 'dojo/text!./templates/TextFilter.html',
 'dijit/form/TextBox'
 ], function(declare, Widget, template) {
 
 return declare(Widget, {
 templateString: template,
 postMixInProperties: function(){ },
 postCreate: function(){ },
 focus: function(){
 this.textbox.focus();
 },
 _setValueAttr: function(value){
 this.textbox.set('value', value);
 },
 
 _getValueAttr: function(){
 return this.textbox.get('value');
 }, Dojo
  • 11. Ember <div class="nav-items">
 {{#each nav as |link|}}
 {{#unless (eq link.state "hidden") }}
 {{#if (eq link.state "disabled") }}
 <div class="side-nav-link {{link.state}}">
 <div class="side-nav-title">{{link.title}}</div>
 </div>
 {{else}}
 {{#link-to link.route title=link.title class=link.state}}
 <div class="side-nav-link {{link.state}}">
 <div class="side-nav-title">{{link.title}}</div>
 </div>
 {{/link-to}}
 {{/if}}
 {{/unless}}
 {{/each}}
 </div>
  • 12. Ember import Ember from ‘ember'; import Navigation from '../../mixins/navigation'; 
 export default Ember.Component.extend(Navigation, {
 classNames: ['side-nav'],
 nav: null, clientId: ‘NA’, activeNavigation: Ember.computed('navigation', function () {
 let activeNavigationObject = [];
 this.get('navigation').forEach((mainItem)=> {
 ...
 });
 return activeNavigationObject;
 }), 
 });
  • 14. Angular <div [ngBusy]="{busy: busy, message: 'Please wait...'}">
 <div *ngIf="settingView">
 <my-actions [links]="settingView.actionUrls"></my-actions>
 </div>
 </div>
  • 15. Angular <h4>Actions</h4>
 <div class="section">
 <a href="{{links[0]}}">Change Your Password</a>
 <a href="{{links[1]}}">Change Your Security Questions</a>
 <a href="{{links[2]}}">Change other usernames for a Single Sign- On Experience</a>
 </div>
  • 16. Angular import { Component, Input, OnInit } from '@angular/core';
 
 @Component({
 moduleId: module.id.toString(),
 selector: 'my-actions',
 templateUrl: 'actions.component.html'
 })
 export class ActionsComponent implements OnInit {
 constructor() { }
 
 @Input()
 links: string[] = [];
 
 ngOnInit() { }
 }
  • 17. React
  • 18. React import React from 'react';
 import { render } from 'react-dom';
 import Text from './form-sections/text';
 export default class Form extends React.Component {
 constructor(props) {
 super(props);
 }
 render() {
 return ( 
 <ay-form ref="form">
 <Text />
 </ay-form> 
 );
 }
 }

  • 19. React import React from 'react';
 import { render } from 'react-dom';
 import pure from 'react-addons-pure-render-mixin';
 
 export default class Text extends React.Component {
 constructor(props) {
 super(props);
 this.shouldComponentUpdate = pure.shouldComponentUpdate.bind(this);
 }
 render() {
 return (
 <section>
 <ay-field type="text" value="" name="where" placeholder="Where"></ay-field>
 </section>
 );
 }
 }
  • 22. JS Frameworks + Web Components • Web Components are “just HTML” so they will work with all of them • It may require some manual wiring, like using addEventListener • With plugins, you can make use of framework template functionality • https://github.com/webcomponents/react-integration • https://github.com/clubajax/react-inject-change-events
  • 24. Web Components Benefits • Part of the DOM - lifecycle tools for free! • Future-proof and cross-browser (web standard) for creating and extending reusable components. • Requires no library or framework to get started. Vanilla JS/HTML FTW! • Provides a familiar programming model. It's just DOM/CSS/HTML. • Creates a very modular system • Tightly integrated with the browser's DevTools. • Leverage existing accessibility features.
  • 25. Web Components • Custom Elements • Shadow DOM • Templates • HTML Imports All four of these items are a WC3 spec, all of which makes up Web Components
  • 26. Custom Elements • Define your own element types and functionality • Provides a standard way to associate JavaScript logic with an element • Lifecycle methods • No confusing context — “this” is the element • Easy to inspect in debuggers We could do custom elements with IE6… the difference is the life cycle methods <x-tabs>
 <ul>Tab 1</ul>
 <ul>Tab 2</ul>
 <ul>Tab 3</ul>
 </x-tabs>
  • 27. Shadow DOM Content can be “projected” into provided slots • Shadow DOM refers to the ability of the browser to include a subtree of DOM elements into the rendering of a document, but not into the main document DOM tree. • CSS style rules are constrained to the shadow tree they were defined in. • The DOM is also encapsulated. For example, document.querySelectorAll('div'); will not return any results from a custom element with Shadow DOM
  • 28. Templates • The template element is used to declare fragments of HTML that can be cloned and inserted in the document by script. • Contains a DocumentFragment in its HTMLTemplateElement.content property
  • 29. HTML Imports <link rel=“import” href=“./my-bugger.html” />
 <link rel=“import” href=“./my-zapper.html” /> • Can import all in one file: JavaScript, HTML, and CSS • Effectively, an HTML document. • HTML Imports can be the dependency management system, replacing AMD or CommonJS • HTML Imports let you include and reuse HTML documents in other HTML documents, just as script tags let you include external JavaScript in their pages.
  • 30. HTML Imports - CONS The HTML Import spec does not have consensus. Mozilla is still holding out, after two years. <link rel=“import” href=“./my-bugger.html” />
 <link rel=“import” href=“./my-zapper.html” /> • Confusing context when importing templates • Spec essentially competes with ES modules • Globals
  • 32. Browser Support • Chrome v54 • WebKit Nightly v18 • Edge has begun prototyping • Firefox has an open bug
  • 34. We need to support old IE because we… • want to expose our servers to unsupported, insecure browsers. • like to pay the extra IE development cost (8:25%, 9:10%, 10:5%). • enjoy tying up QA to spend extra time testing more browser versions https://www.xfive.co/blog/stop-supporting-ie10-ie9-ie8/ Seriously, management often encourages the support of old versions because they are not aware of the cost and risk.
  • 35. Polyfills • A polyfill for HTML Custom Elements. • ShadyDOM provides a shim for ShadowDOM V1. It is less correct but less intrusive and faster than the ShadowDOM Polyfill. • ShadyCSS provides a shim for CSS Custom Properties, CSS Mixins with @apply support, and ShadowDOM V1 style encapsulation with the ShadyDOM library.
  • 36. v0 vs v1* *The differences between the old spec and the recent changes
  • 37. v0 var proto = Object.create(HTMLElement.prototype);
 proto.createdCallback = function() {
 // invoked on creation
 };
 proto.attachedCallback = function() {
 // invoked when added to the document
 };
 proto.detachedCallback = function() {
 // invoked when removed from the document
 };
 proto.attributeChangedCallback = function(attrName, oldVal, newVal) {
 // invoked when an attribute is changed
 }; 
 var MyComponent = document.registerElement('my-component', {
 prototype: proto
 });
  • 38. class MyComponent extends HTMLElement {
 static get observedAttributes() { return ['value', 'disabled']; }
 constructor ( ) {
 super();
 }
 connectedCallback ( ) { }
 disconnectedCallback ( ) { }
 attributeChangedCallback(attrName, oldVal, newVal) { }
 adoptedCallback() { }
 }
 customElements.define('my-component', MyComponent); v1 constructor: the element is created or upgraded connectedCallback: the element is inserted into the DOM disconnectedCallback: the element is removed from the DOM. attributeChangedCallback: an attribute was added, removed, or updated adoptedCallback the element has been moved into a new document define: exposes the element name for use in markup
  • 39. History Q: Why did the spec change? A: The old spec did not work with ES6 classes Q: Does the new spec work wth ES5? A: uh, sort of… Q: Who changed it? A: Blame Apple's Ryosuke Niwa. He’s made a few changes… Q: Should I wait to use Web Components until v1 is implemented? A: No, not any more than you would wait for any other shim-able browser feature
  • 40. Inheritance class MyButton extends HTMLButtonElement {
 constructor () {
 super(...arguments);
 }
 }
 customElements.define('my-button', MyButton, {extends: 'button'}); Extends something other than HTMLElement Extra argument when defining Blocked by Apple. Use native tag, and extended tag in “is” This is what it would look like… if it were implemented.
  • 41. ES6 Classes class MyComponent extends HTMLElement {
 static something () { return 'something'; }
 constructor () {
 super();
 }
 connectedCallback () {
 //
 }
 } always call super() first in the constructor. “this” is not established until after Commas are forbidden to emphasize that class definitions are different from object literals. Classes are sugar for prototypal inheritance. MyComponent is a function that inherits from the HTMLElement prototype. static is similar to: MyComponent.something = function () { return ’something’; } data properties are not allowed like in objects: {a: true} (yet) getters and setters must be used. super is used as a function in the constructor, as property references: super.someMethod();
  • 42. Custom Element API Considerations • Sync important properties with attributes • getters/setters over methods • Broadcast changes via events • Use standard properties and event names (“value”, “change”) • innerHTML — what happens, before and after initialization? • Appending children • Use :defined or alternative • Consider Shadow DOM styling pros and cons
  • 43. DEMOS
  • 44. Refs https://github.com/webcomponents/shadydom https://github.com/webcomponents/shadycss https://webkit.org/blog/7027/introducing-custom-elements/ https://github.com/webcomponents/react-integration https://github.com/clubajax/react-inject-change-events https://hacks.mozilla.org/2014/12/mozilla-and-web-components/ https://www.polymer-project.org/1.0/blog/2016-12-21-polymer-2.0-update https://developers.google.com/web/fundamentals/getting-started/primers/customelements?hl=en#historysupport https://twitter.com/AaronGustafson/status/717028669948977153 https://github.com/w3c/webcomponents/issues/509