A Marklar walks into a Marklar. Marklar asks the marklar, "do you have any Marklar?"
The Marklar shakes his Marklar and says "No, we only have Marklar"
This has been an exercise in...
<marklar style="background-image: url(marklar.gif);">
<marklar>Marklar was a secret Apple development program
to put Mac OS X on the Intel x86 microprocessor. Ten years
ago, the first rumors of Marklar emerged.</marklar>
<marklar href="#" onclick="doMarklar()">More</marklar>
</marklar>
New standards moving through the W3C
Encapsulation by hiding DOM subtrees under shadow roots
Source: Simply Scheme, Chapter 18: Trees
Source: W3C Shadow DOM Specification
var template = document.querySelector('template'),
tacoSurprise = Object.create(HTMLElement.prototype);
tacoSurprise.createdCallback = function() {
var shadowRoot = this.createShadowRoot(),
clone = template.content.cloneNode(true);
shadowRoot.appendChild(clone);
template.remove();
};
document.registerElement("taco-surprise", {
prototype: tacoSurprise
});
Source: Caniuse.com
*Shadow DOM coming soon
How to add semantics
var TacoButtonPrototype = Object.create(HTMLButtonElement.prototype);
var TacoButton = document.registerElement('taco-button', {
prototype: TacoButtonPrototype,
extends: 'button'
});
var tacoButton = new TacoButton();
document.body.appendChild(tacoButton).textContent = 'Give me tacos';
tacoButton = document.querySelector('button[is=taco-button]');
How to add semantics
<taco-surprise>
<h2>Taco Surprise!</h2>
<button>Give me tacos</button>
<output>
<img src="" alt="" aria-hidden="true">
<p class="error hidden">Or give me death</p>
</output>
</taco-surprise>
How to add semantics
ARIA and Tab Index
<taco-button role="button" tabIndex="0">tacos!</taco-button>
<pork-slider role="slider" aria-valuemin="1" aria-valuemax="5"
aria-valuenow="0"></pork-slider>
Source: are we componentized yet?
Note: this stuff moves fast!