JSPM

  • Created
  • Published
  • Downloads 68
  • Score
    100M100P100Q52293F
  • License MIT

Create an EventTarget associated with the adorned element that can hold scoped state.

Package Exports

    Readme

    be-scoped

    Create an EventTarget associated with the adorned element that can hold scoped state.

    <div id="scoped" be-scoped='{"count": 30}'></div>

    ...results in:

    console.log(scoped.beEnhanced.beScoped.scope.count === 30)
    //true

    To subscribe to changes to the scope:

    await customElements.whenDefined('be-enhanced');
    const beScoped = await scoped.beEnhanced.whenResolved('be-scoped');
    beScoped.scope.addEventListener('count', e => {
        console.log(e.detail);
    });

    Adorning a custom element

    If the desire is to add "scoping" to a custom element, use be-propagating instead.

    Playwright Tests NPM version

    Size of package, including custom element behavior framework (be-enhanced/be-hive):

    How big is this package in your project?

    Size of new code in this package:

    Viewing Locally

    1. Install git.
    2. Fork/clone this repo.
    3. Install node.
    4. Open command window to folder where you cloned this repo.
    5. npm install

    6. npm run serve

    7. Open http://localhost:3030/demo/ in a modern browser.

    Importing in ES Modules:

    import 'be-exportable/be-scoped.js';

    Using from CDN:

    <script type=module crossorigin=anonymous>
        import 'https://esm.run/be-scoped';
    </script>