简体   繁体   English

JS错误:要删除的节点不是该节点的子节点

[英]JS Error: The node to be removed is not a child of this node

I have two autocomplete textbox on the page to do some advance search in my project. 我在页面上有两个自动完成文本框,可以在项目中进行一些高级搜索。 I am getting an error like Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. 我收到类似Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.的错误Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. while removing a manual input on the second time. 同时第二次删除手动输入。

I have used facebook autocomplete plug-in. 我使用了Facebook自动完成插件。 Please find my JS Fiddle Demo I have a problem once entered the text on the autocomplete and hit enter key to hide the manual input on the textbox. 请找到我的JS小提琴演示,一旦在自动完成功能上输入了文本,然后按Enter键以隐藏文本框上的手动输入,我就遇到了问题。 It is happening on the the first box but it fails on the second box. 它在第一个框上发生,但在第二个框上失败。

My Demo looks like below 我的演示如下

Any help on this..? 任何帮助..?

You should understand what happens is error line React lib contains DOMChildrenOperations.js and here is function 您应该了解发生了什么错误行React lib包含DOMChildrenOperations.js ,这是函数

function removeChild(parentNode, childNode) {
  if (Array.isArray(childNode)) {
    var closingComment = childNode[1];
    childNode = childNode[0];
    removeDelimitedText(parentNode, childNode, closingComment);
    parentNode.removeChild(closingComment);
  }
  parentNode.removeChild(childNode);
}

The reason in your case is that mockup is different at initial state and while React try to update your DOM, because of 3th party DOM manipulate library. 您的情况是,由于第3方DOM操作库,模型在初始状态下有所不同,而React尝试更新您的DOM时。 For me the same error occurred because childNode in my case was 2 dome nodes for fix this I just added one more div like parent for my element which was edited by 3th party library 对我来说,发生相同的错误是因为在我的情况下childNode是2个圆顶节点以解决此问题, 我只是为我的元素添加了一个像父元素一样的div ,该元素由第3方库编辑

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM