require(["delite/register"], function (register) {
register(tag, superclasses, props) → {function};
});
Declare a widget and register it as a custom element.
props{} can provide custom setters/getters for widget properties, which are called automatically when the widget properties are set. For a property XXX, define methods _setXXXAttr() and/or _getXXXAttr().
Parameters:
Name | Type | Description |
---|---|---|
tag |
string | The custom element's tag name. |
superclasses |
Array.<Object> | Any number of superclasses to be built into the custom element constructor. But first one must be [descendant] of HTMLElement. |
props |
Object | Properties of this widget class. |
- Source:
Returns:
A constructor function that will create an instance of the custom element.
- Type
- function
Methods
-
<static> after()
-
Convenience shortcut to dcl.after().
- Source:
-
<static> around()
-
Convenience shortcut to dcl.around().
- Source:
-
<static> before()
-
Convenience shortcut to dcl.before().
- Source:
-
<static> createElement(tag) → {Element}
-
Create an Element. Similar to document.createElement(), but if tag is the name of a widget defined by register(), then it upgrades the Element to be a widget.
Parameters:
Name Type Description tag
string - Source:
Returns:
The DOMNode
- Type
- Element
-
<static> dcl()
-
Convenience shortcut to dcl().
- Source:
-
<static> parse(root)
-
Parse the given DOM tree for any Elements that need to be upgraded to widgets. Searches all descendants of the specified node, but does not upgrade the node itself.
Usually the application will not need to call this method directly, because it's called automatically on page load and as elements are added to the document.
Parameters:
Name Type Argument Description root
Element <optional>
DOM node to parse from.
- Source:
-
<static> superCall()
-
Convenience shortcut to dcl.superCall().
- Source:
-
<static> upgrade(element, attach)
-
Converts plain Element of custom type into "custom element", by adding the widget's custom methods, etc. Does nothing if the Element has already been converted or if it doesn't correspond to a registered custom tag. After the upgrade, calls
createdCallback()
.Usually the application will not need to call this method directly, because it's called automatically on page load and as elements are added to the document.
Parameters:
Name Type Argument Description element
Element The DOM node.
attach
boolean <optional>
If
element
's tag has been registered, butattachedCallback()
hasn't yet been called [since the last call todetachedCallback()
], then callattachedCallback()
. Call even if the element has already been upgraded.- Source: