Methods
(static) define(tagName, cl)
Define a custom element definition. It will only define a tag name once
and will log an error if there's an attempt to define a tag name a second
time. This is useful for tests since you can't undefine a custom element.
See also https://github.com/karma-runner/karma/issues/412
Parameters:
Name | Type | Description |
---|---|---|
tagName |
string | The name of the tag. |
cl |
function | The class for the given tag. |
Example
Instead of:
window.customElements.define('my-element', class extends HTMLElement {...});
Use:
import { define } from 'elements-sk/define'
define('my-element', class extends HTMLElement {...});