SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
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
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

Contenu connexe

Tendances

[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 JSIvano Malavolta
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX DesignersAshlimarie
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkBorisMoore
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in ComponentsFITC
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web ComponentsRich 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 TemplatesBorisMoore
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideMark 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 2015Matt Raible
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can buildMonika 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 JAVAYash 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 & PolymerErik Isaksen
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterpriseDave 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 CombinationAndrew 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 RefresherIvano Malavolta
 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Trainingubshreenath
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsAviran Cohen
 

Tendances (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
 
Web Development for UX Designers
Web Development for UX DesignersWeb Development for UX Designers
Web Development for UX Designers
 
Harness jQuery Templates and Data Link
Harness jQuery Templates and Data LinkHarness jQuery Templates and Data Link
Harness jQuery Templates and Data Link
 
Web Components
Web ComponentsWeb Components
Web Components
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
 
HTML5, just another presentation :)
HTML5, just another presentation :)HTML5, just another presentation :)
HTML5, just another presentation :)
 
JsViews - Next Generation jQuery Templates
JsViews - Next Generation jQuery TemplatesJsViews - Next Generation jQuery Templates
JsViews - Next Generation jQuery Templates
 
SPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuideSPSNH 2014 - The SharePoint & jQueryGuide
SPSNH 2014 - The SharePoint & jQueryGuide
 
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
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can build
 
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
 
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
 
What is jQuery?
What is jQuery?What is jQuery?
What is jQuery?
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
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
 
HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술HTML5와 오픈소스 기반의 Web Components 기술
HTML5와 오픈소스 기반의 Web Components 기술
 
[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher[2015/2016] HTML5 and CSS3 Refresher
[2015/2016] HTML5 and CSS3 Refresher
 
HTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery TrainingHTML CSS JavaScript jQuery Training
HTML CSS JavaScript jQuery Training
 
ME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS FundamentalsME vs WEB - AngularJS Fundamentals
ME vs WEB - AngularJS Fundamentals
 

Similaire à Web Components and JS Frameworks

Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introductioncherukumilli2
 
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 arrivedGil Fink
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web FrameworkLuther 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 arrivedGil 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
 
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 TornadoGavin 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_HourDilip 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 bhatiasapientindia
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenerytoddbr
 
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 SharePointMark Rackley
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architectureJasper Moelker
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan 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 arrivedGil 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_2016Roy de Kleijn
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPOscar Merida
 

Similaire à Web Components and JS Frameworks (20)

Web components - An Introduction
Web components - An IntroductionWeb components - An Introduction
Web components - An Introduction
 
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
 
Apache Wicket Web Framework
Apache Wicket Web FrameworkApache Wicket Web Framework
Apache Wicket Web Framework
 
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]
 
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
 
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!
 
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...
 
An Introduction to Tornado
An Introduction to TornadoAn Introduction to Tornado
An Introduction to Tornado
 
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...
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
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...
 
Rp 6 session 2 naresh bhatia
Rp 6  session 2 naresh bhatiaRp 6  session 2 naresh bhatia
Rp 6 session 2 naresh bhatia
 
Javascript first-class citizenery
Javascript first-class citizeneryJavascript first-class citizenery
Javascript first-class citizenery
 
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
 
Voorhoede - Front-end architecture
Voorhoede - Front-end architectureVoorhoede - Front-end architecture
Voorhoede - Front-end architecture
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
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
 
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
 
ReactJS.ppt
ReactJS.pptReactJS.ppt
ReactJS.ppt
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 

Plus de Mike Wilcox

Accessibility for Fun and Profit
Accessibility for Fun and ProfitAccessibility for Fun and Profit
Accessibility for Fun and ProfitMike 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 itMike Wilcox
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsMike Wilcox
 
Model View Madness
Model View MadnessModel View Madness
Model View MadnessMike Wilcox
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightMike Wilcox
 
The Great Semicolon Debate
The Great Semicolon DebateThe Great Semicolon Debate
The Great Semicolon DebateMike Wilcox
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and HowMike Wilcox
 
Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersMike 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 DeveloperMike Wilcox
 
A Conversation About REST
A Conversation About RESTA Conversation About REST
A Conversation About RESTMike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5Mike Wilcox
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5Mike 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 DeveloperMike Wilcox
 
The History of HTML5
The History of HTML5The History of HTML5
The History of HTML5Mike Wilcox
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?Mike Wilcox
 

Plus de Mike Wilcox (20)

Accessibility for Fun and Profit
Accessibility for Fun and ProfitAccessibility for Fun and Profit
Accessibility for Fun and Profit
 
WTF R PWAs?
WTF R PWAs?WTF R PWAs?
WTF R PWAs?
 
Advanced React
Advanced ReactAdvanced React
Advanced React
 
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
 
Dangerous CSS
Dangerous CSSDangerous CSS
Dangerous CSS
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
Model View Madness
Model View MadnessModel View Madness
Model View Madness
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it Right
 
The Great Semicolon Debate
The Great Semicolon DebateThe Great Semicolon Debate
The Great Semicolon Debate
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and How
 
Dojo & HTML5
Dojo & HTML5Dojo & HTML5
Dojo & HTML5
 
Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-Designers
 
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
 
A Conversation About REST
A Conversation About RESTA Conversation About REST
A Conversation About REST
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
 
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
 
The History of HTML5
The History of HTML5The History of HTML5
The History of HTML5
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
 
Flash And Dom
Flash And DomFlash And Dom
Flash And Dom
 

Dernier

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
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
 
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
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 

Dernier (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
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
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
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?
 
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.
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
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
 
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
 
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
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 

Web Components and JS Frameworks

  • 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
  • 4.
  • 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