• Returns a proxy object that selects an element when a property is requested from it. Setting a property will also replace the selected element and deleting a property will remove the selected element.

    By default it uses querySelector for string keys and children for number keys.

    Parameters

    • Optional treespace: Element

    Returns any

    Example

    import { selector } from 'deleight/proxy/selector';
    document.body.innerHTML = `
    <div>I am a div</div>
    <p>I am a paragraph</p>
    <section>I am a section</section>
    <article>I am an article</article>
    `;
    const slct = selector(document.body);
    console.log(slct.article.textContent); // I am an article