Skip to content

About

An utility to simplify Custom Elements instantiation for every browser

Resources

Stars

15 stars

Watchers

1 watching

Forks

Latest commit

 

History

8 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CustomElement.new()

An utility to simplify Custom Elements instantiation for every browser, specially those incapable of extending built-ins.

Please note that while this module by its own works out of the box in WebKit/Safari, as in every other browser, you still need to polyfill Custom Elements built-in extends for these, and before using this helper.

class MyButton extends HTMLButtonElement {}
customElements.define('my-button', MyButton, {extends: 'button'});

// Safari would fail at using `new MyButton()`
// Safari would indeed need `document.createElement('button', {is: 'my-button'})`
// With this utility/helper though, you can simply write instead:
const mybtn = MyButton.new(); // 🎉

About

An utility to simplify Custom Elements instantiation for every browser

Resources

Stars

15 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages