A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.
To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).
Component Model: Difference between revisions
Line 22: | Line 22: | ||
==Extensibility== | ==Extensibility== | ||
The component model must enable creation of new types of DOM elements by | The component model must enable creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here's how you might create a new sub-type of HTMLElement: | ||
<code> | <code> | ||
<pre> | <pre> | ||
Line 44: | Line 44: | ||
</code> | </code> | ||
The resulting <code>panel</code> instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. | The resulting <code>panel</code> instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance. | ||
Implementation details: | Implementation details: |
Revision as of 18:03, 18 August 2011
Here's a good starting point for learning about the component model spec, which is currently under development (also see periodically updating gh-pages).
Introduction
TODO Populate with beautifully crafted words.
Overview
Composability
Consistency
Encapsulation
Isolation
Extensibility
The component model must enable creation of new types of DOM elements by allowing the use of existing DOM elements in Javascript prototype chain. For example, here's how you might create a new sub-type of HTMLElement:
function LayoutManagerPanel() {
HTMLElement.call(this);
}
LayoutManagerPanel.prototype = Object.create(HTMLElement.prototype);
// ...
// 1) Will not be able to add instances of LayoutManagerPanel to document without this call.
// 2) First parameter must be a string prefixed with "x-" and specifies the tagName of the element being registered.
Element.register("x-layout-manager-panel", LayoutManagerPanel);
// ...
var panel = new LayoutManagerPanel();
The resulting panel
instance is a Javascript object that is a valid DOM element, which can be added to the DOM tree. You can then extend this object using standard Javascript prototype inheritance.
Implementation details:
- Make calling constructors of DOM elements possible.
- Implement
Element.register
.
Desugaring
Differences From Existing Specs
Templates
Events
Attachment
Styles
<style scoped> is a natural way to limit style sheets to only affect the shadow tree of a component. The component model follows the implementation suggested in this www-style thread. That is, a selector is only matched up to, and including, the scoping element - i.e., the parent element of <style scoped> - but not further. The exceptions are:
- the selector contains the :root pseudo-class (note that this will fail if not used within the first selector sequence), or
- the selector contains the :scope pseudo-class
CSS4: care must be taken that the subject of a selector is the scoping element or a descendant thereof.
[TODO: notes on crossing the boundary from/into the shadow tree]