ActuatorElements
NOTE: It works on latest versions of Chrome, Firefox and Safari. IE never supported. CAUTION: It doesn't work well on Edge currently, but it will be supported soon.
ActuatorElements consist of some custom elements, and bring an template system to html. They depend on Web Components(webcomponents-lite.js polyfill), but not on any other frameworks like Polymer or X-Tag.
ActuatorElements can bind data to an element. However, they can not detect data changes: You need to notify updates to the element manually. If you want to do it automatically, you can use MechanicalElements instead. They are the reactive(without dirty checking!) version of ActuatorElements.
Examples
${ message }
${ capitalize(name) } is ${ color }.
Install
$ npm install --save actuator-elements
$ bower install --save actuator-elements
API
All ActuatorElements support interpolation in JavaScript way: ${ ... }. In addition, they have these interfaces.
JavaScript Interface
- bindData(data, utils)
- unbindData()
- notifyUpdate(name)
- notifyUpdateAll()
- boundData: read only
Attribute Interface
- data-bind
- data-json
- data-template
ActPutElement
count = ${ count }
ActEachElement
JavaScript API
- notifySplice(index, removedCount, addedCount)
- notifySpliceAll()
- childCreatedCallback(child::document fragment, data, { index })
- childDetachedCallback(child::document fragment, data, { index })
C2H${ index * 2 }: ${ name }
ActRegisterElement
Attribute Interface
- data-tag-name: required
- data-extends
<!-- dynamic languages only displayed --> ${ name }
ActFormElement
ActFormElement and ActInputElement can automatically detect form changes and reflect them in bound data.
Attributes
- data-updateOn
ID: PASSWORD: Your password is too weak...
ActInputElement
NOTE: type="radio" not supported
Tips
Extension
One of the advantages to use ActuatorElements is high extendability.
{ if thiscontentchildrenlength !== 1 throw 'child length must be 1'; // CAUTION: Don't forget to call super.lifecycleCallback super; } { const boundData = this; // NOTE: child is document fragment childfirstElementChilddraggable = true; childfirstElementChild; childfirstElementChild; childfirstElementChild; } document;
De-ActuatorElements
You can change the register name not to pollute your namespace.
const act = ; // register act-each as 'my-each'document;
// Or you can register all elements with 'my-' prefix act;