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 Strawman: Isolation: Difference between revisions
mNo edit summary |
(Add considerations section) |
||
Line 1: | Line 1: | ||
= Overview = | = Overview = | ||
== Terms == | |||
* '''Confined''': disallow a component from accessing the containing page. Useful when a page does not trust the component or its source. | |||
* '''Encapsulated''': disallow the containing page from accessing the internals of the component. Useful when a component wants to prevent a page from meddling with it. | |||
* '''Isolated''': a component that is both confined and encapsulated. | |||
== Considerations == | |||
To facilitate component isolation: | |||
=== Autonomy === | |||
Components should be autonomous entities that can be loaded and applied as a single building block. Avoid requiring extensive manipulations on both side of the page <=> component divide. | |||
This will also help in implementing decorators. | |||
=== Interface === | |||
The interface of a component should be minimal and well defined. Embedding pages should not be required (nor able to in the case of encapsulation) to access, or even know about, the internals of a component. Conversely, the function of a component should not depend on being able to access the DOM or any other information of the hosting page that is not provided through an interface. | |||
The component should be able to apply and filter data and styles passed in as it sees fit. | |||
= Element Registration and HTMLElementProxy = | |||
The isolated components definition is a <tt>provide</tt> attributed HTML file which is loaded in separate namespace. | The isolated components definition is a <tt>provide</tt> attributed HTML file which is loaded in separate namespace. | ||
Line 5: | Line 29: | ||
See also the "Isolation" section on [[Component_Model_Strawman:_Declarative_Syntax]]. | See also the "Isolation" section on [[Component_Model_Strawman:_Declarative_Syntax]]. | ||
* XXX: define the element name resolution order. | * XXX: define the element name resolution order. |
Revision as of 19:56, 25 October 2011
Overview
Terms
- Confined: disallow a component from accessing the containing page. Useful when a page does not trust the component or its source.
- Encapsulated: disallow the containing page from accessing the internals of the component. Useful when a component wants to prevent a page from meddling with it.
- Isolated: a component that is both confined and encapsulated.
Considerations
To facilitate component isolation:
Autonomy
Components should be autonomous entities that can be loaded and applied as a single building block. Avoid requiring extensive manipulations on both side of the page <=> component divide.
This will also help in implementing decorators.
Interface
The interface of a component should be minimal and well defined. Embedding pages should not be required (nor able to in the case of encapsulation) to access, or even know about, the internals of a component. Conversely, the function of a component should not depend on being able to access the DOM or any other information of the hosting page that is not provided through an interface.
The component should be able to apply and filter data and styles passed in as it sees fit.
Element Registration and HTMLElementProxy
The isolated components definition is a provide attributed HTML file which is loaded in separate namespace. It is basically a document loaded by an iframe. But it has different way for communicating with the host document.
See also the "Isolation" section on Component_Model_Strawman:_Declarative_Syntax.
- XXX: define the element name resolution order.
Isolated providing document can register new elements for the host document. But in slightly different way: the lifecycle callbacks including open and close use HTMLElementProxy instead of HTMLElement, that means open should return an instance of HTMLElementProxy and close callback receives it as a parameter.
<head> <element for="x-comment"> <script> HTMLElementElement.current.open = function() { var element = return new HTMLElementProxy(); element.addEventListener("message", ... return element; }}); </script> </element> </head>