Function selectorSetter

  • Returns a component that sets the selected members as properties on the element using the keys associated with the selectorAttr.

    Parameters

    • selectorAttr: string = 'm-ember'

    Returns ((element) => void)

      • (element): void
      • Parameters

        • element: Element

        Returns void

    Example

    import { listener } from 'deleight/dom/components'
    import { apply } from 'deleight/dom/apply'

    document.body.innerHTML = `
    <div>I am a div</div>
    <p m-ember="about">I am a paragraph</p>
    <section>I am a section <button m-ember="b1">Btn1</button></section>
    <article>I am an article <button m-ember="b2">Btn2</button></article>
    `;

    const comp = selectorSetter()
    comp(body);
    document.body.about;
    document.body.b1;
    document.body.b2;