custom-element

2.1.0 • Public • Published

custom-element

Experimental: convenience wrapper for creating custom element prototypes.

require('webcomponents.js')
 
var createCustom = require('custom-element')
 
var CustomHTMLElement = createCustom(function() {
  // created
}).on('created', function() {
  // alternative syntax for created
}).on('attached', function() {
  // attached to the DOM
}).on('detached', function() {
  // detached from the DOM
}).on('attribute', function(value) {
  // when an attribute is changed via setAttribute.
  // Note that values are coerced into strings.
})
 
document.registerElement('custom-element', CustomHTMLElement)

Package Sidebar

Install

npm i custom-element

Weekly Downloads

2

Version

2.1.0

License

MIT

Last publish

Collaborators

  • hughsk
  • timoxley
  • yoshuawuyts