question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DOMException: The supplied node is incorrect or has an incorrect ancestor for this operation.

See original GitHub issue

Hi Andrea,

I have a strange bug. Maybe it is because of nesting things in the wrong way.

It happens at: http://rdf-form.danielbeeke.nl/ If you scroll down till you see a form. There is a field Author. If you empty it, type something that it would not find, click on Add sghfghdg as text without reference.. Then it will crash with:

DOMException: The supplied node is incorrect or has an incorrect ancestor for this operation.

Source code: https://github.com/danielbeeke/rdf-form/blob/master/src/RdfForm.ts https://github.com/danielbeeke/rdf-form/blob/master/src/FormElements/FormElementBase.ts

I have not yet used html.for(object)`` at that place I do not have an object. I only have a key. Would .for help in this situation?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
WebReflectioncommented, Nov 27, 2020

In few words, don’t over-cache anything, as the result will be likely slower instead, and you’re not supposed to manually move parts around, that’s responsibility of udom to drop, add, or move, nodes … you never need to take care but if you need same node as reference, you need to use .for(...)

1reaction
WebReflectioncommented, Nov 27, 2020

In any case, if by “save parts into a variable and use that variable multiple times” you mean store a node into a variable, you can’t reuse that variable in more than a place for the simple reason that a node is a node, and the tree-differ can’t do anything if you arbitrary moves nodes that the tree-differ is handling already.

Is this okay?

no, it’s not, you’re moving a node manually around and you shouldn’t.

On top of that, this.remove() won’t remove the element but its outer most container, if it’s a DOM node, or it throws … that’s an arrow function, the context in your example is unknown.

If I change to …

to be honest, I’d write this one:

const remove = () => this.remove();
const context = html`<div>${a ?
  html`<div><button onclick=${remove}>Remove</button></div>` :
  html`<span><button onclick=${remove}>Remove</button</span>`
}</div>`;
Read more comments on GitHub >

github_iconTop Results From Across the Web

DOMException - Web APIs | MDN
The DOMException interface represents an abnormal event (called ... The node is incorrect or has an incorrect ancestor for this operation.
Read more >
why does this piece of js throw a DOM Exception?
The problem is the status not available when the readyState is 0/1. You need to reverse the order in your if. if(xhr.
Read more >
DOM - DOMException Object - Tutorialspoint
The node is incorrect or has an incorrect ancestor for this operation. (Legacy code value: 24 and legacy constant name: INVALID_NODE_TYPE_ERR).
Read more >
DOMException - Web APIs
The DOMException interface represents an abnormal event (called an exception) ... The node is incorrect or has an incorrect ancestor for this operation....
Read more >
DOMException | Aspose.HTML for .NET API Reference
The DOMException interface represents an abnormal event called an ... The supplied node is incorrect or has an incorrect ancestor for this operation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found