Define and register a new custom element.
xtag.register(NAME, DEFINITION)
xtag.register(NAME, DEFINITION)
Argument | Type | Description |
---|---|---|
NAME | String | The custom element's tag name (must contain a dash) |
DEFINITION | Object | An object containing the various features your custom element will utilize |
xtag.register('x-shouter', {
content: '<input type="text" />',
lifecycle:{
created: function(){
alert(this.firstElementChild);
// Alerts the input specified via the 'content' property
}
},
methods: {
shout: function(message){
setTimeout(function(){
alert(message);
}, this.delay);
}
},
accessors: {
delay: {
attribute: {}
}
},
events: {
tap: function(){
this.shout(this.firstElementChild.value);
}
}
});