WebComponents and modern web frameworks |
|
Ahmad Atighechi @ahmad2x4 |
Turbo Vision (text base UI control set)
Visual InterDev (calendar component)
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Probably a twitter bootstrap page
Current developers' experience in reusing widgets is really poor
<iframe src="foo.htm"></iframe>
Hello World
var template = document.querySelector('#foo');
var container = document.querySelector('#container');
var clone = document.importNode(template.content, true);
//Creating shadow root and appending cloned template
var root = container.createShadowRoot();
root.appendChild(clone);
//To check if browser support native template
if ('content' in document.createElement('template')){
}
Note: Default template implementation doesn't come with if, repeat
How do I use WebComponent in my HTML page
Comment 2
Comment 2
Asnwer 1
Commnet 3
var XFavButton = document.registerElement('stack-favorite-button');
document.body.appendChild(new XFavButton());
Or
var XFavButton = document.registerElement('stack-favorite-button',{
prototype: Object.create(HTMLButtonElement.prototype),
extends: 'button'
}
);
document.body.appendChild(new XFavButton());
javascript..... <script/>
image.......... <img/>
css............ <link/>
video.......... <video/>
HTML........... ????
<head>
<link rel="import" href="/path/to/imports/stuff.html">
</head>
<script>
var link = document.querySelector('link[rel="import"]');
var content = link.import;
// Clone the <template> in the import.
var template = content.querySelector('template');
var clone = document.importNode(template.content, true);
document.querySelector('#container').appendChild(clone);
</script>
Chrome | Opera | Firefox | Safari | Edge | |
Templates | 26 | 15 | 22 | 7.1 | 13 |
HTML Imports | 36 | 23 | On Hold | Low | |
Custom Elements | 33 | 20 | Behind Flag | in dev | Medium |
Shadow DOM | 25 | 15 | Behind Flag | in dev | High |
What does community do with in-progress standard?
Webcomponentjs
bower install --save webcomponentsjs
Shadow DOM | |
HTML Import | |
HTML Template | |
Custom Element |
Shadow DOM | |
HTML Import | |
HTML Template | |
Custom Element |
Includes all polyfills except for shadow DOM.
Shadow DOM | |
HTML Import | |
HTML Template | |
Custom Element |
Shadow DOM | |
HTML Import | |
HTML Template | |
Custom Element |