as-custom-element
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

As Custom Element

The easiest way to add Custom Elements like callbacks to any node.

Compatible with modern browsers, as well as IE11, and no polyfills are needed, for a minified size less than 0.8K.

import {upgrade, downgrade} from 'as-custom-element';

const someBehavior = {
  // lifecycle callbacks
  connectedCallback() {
    console.log(this, 'is connected');
  },
  disconnectedCallback() {},

  // attributes related helpers
  observedAttributes: ['one', 'or', 'more'],
  attributeChangedCallback(attributeName, oldValue, newValue) {}
};

upgrade(document.querySelector('#any'), someBehavior);

// to drop the behavior at any time
downgrade(document.querySelector('#any'), someBehavior);

Package Sidebar

Install

npm i as-custom-element

Weekly Downloads

212

Version

2.0.1

License

ISC

Unpacked Size

19.8 kB

Total Files

11

Last publish

Collaborators

  • webreflection