com•po•nent•ta•ry (kəm-pōˈnəntˈtə-rē, -trē) That serves to component something.
Library to construct custom components (i.e. Element tree). It tries to emulate the behavior of Web Components while being native HTML.
Simply load the componentary.js
file. The components
global object contains the library.
This library provides two useful methods: registerElement
and createElement
.
To register a component, components.registerElement
must be called with:
- (
string
) A name to identify the component - (
string
) A template containing the component' members (elements) - (
object
) A prototype defining its behavior. The prototype can contain the following methods:- (
function
) A callback (createdCallback
) to call when an instance of the component is created. - (
function
) A callback (attachedCallback
) to call when the component is actually attached to theDocument
. - (
function
) A callback (attributeChangedCallback
) to call when attributes of the component instance are changed.
- (
When a component is registered, it cannot be deleted nor changed until reloading.
When a component is registered, an instance of that component can be created with the components.createElement
method. The function returns a DocumentFragment
that can be attached to a Document
.
This directory and the whole project is subject to the MIT License.