typeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node Polymer

typeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node Polymer

我正在尝试使用聚合物纸菜单实现上下文菜单。每当我从 dom 中删除节点时。 polymer 抛出这样的错误

typeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'

我收到以下错误消息:

我该怎么办?

我遇到了同样的问题。这是由于 polymer-mini.html 检查传递给 document.documentElement.contains(node) 的 arg 是否是节点类型。调试我可以看到一个事件传播所以最后一次迭代是 window 对象导致这个问题。 我的解决方案是在删除操作之前将 ev.stopPropagation() 添加到代码中。