0

On click of a div i am trying clear the content and I am making it editable. so when i try to get the innerHTML it has no issues but when i try to modify the innerHTML , i get a console error as below in my salesforce local development server

lwc:dom error on console

So then i tried to add in the mentioned lwc:dom="manual"

I get an error like below

enter image description here

the javascript line caused the console error is event.target.innerHTML = "";

toggleEditable(event){
       
        //Remove the place holder text on click
        if(event.target.innerHTML == 'Click to enter the minutes'){
            event.target.innerHTML = "";
            this.cloneDefaultRow(this);
        }
        //Toggle editable to true for the clicked item
        event.target.setAttribute('contenteditable', 'true');
        event.target.focus();
    }

I am not sure how to overcome this console error even though the functionality is not interrupted for now.

1 Answer 1

0

I'm pretty sure they don't want you to do that. I've been reading through the source and just happened to be at this section in @lwc/engine-core:

    innerHTML: generateAccessorDescriptor({
        get() {
            return originalInnerHTMLDescriptor.get.call(this);
        },
        set(_value) {
            throw new TypeError(`Invalid attempt to set innerHTML on HTMLElement.`);
        },
    }), ...

I'm not sure which file specifically though because I'm reading the compiled code.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .