1

I am trying to expand HTML Element and I have a problem. Can't Custom Elements be defined in LWC?

Script

export default class DropBox extends LightningElement {
    connectedCallback(){
        // Input Element Extend
        class DropBoxInput extends HTMLInputElement {
            constructor() {
                super();
                this.addStyle();
            }
            addStyle(){
                // Some Style...
            }
        }
        customElements.define('dropBox-input',DropBoxInput,{extends:'input'});
   }
}

Template

<template>
    <input type="text" is="dropBox-input"/>
</template>

When I tried to save the code, I got a message that the "is" property was not available.

Is there a way to define Custom Element at LWC?

0

according to documents, The secure window does not support 'Custom Element'

Thus, it seems impossible for developers to define Custom Element or expand the Standard Element within the Lightning Web component.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.