typeError:无法在“节点"上执行“包含":参数1不是“节点聚合物"类型 [英] typeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node Polymer

查看:90
本文介绍了typeError:无法在“节点"上执行“包含":参数1不是“节点聚合物"类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to implement context menu using polymer paper menu. Whenever I remove node from dom. polymer is throwing error like this

typeError:无法在节点"上执行包含":参数1的类型不是节点"

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

,我收到以下错误消息:

and I get the following error message:

我该怎么办?

推荐答案

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

I had the same issue. This is due to polymer-mini.html checks if the arg passed to document.documentElement.contains(node) is node type. Debugging i could see that an event propagated so the last iteration was window object causing this issue. My solution was adding ev.stopPropagation() to the code before removing action.

这篇关于typeError:无法在“节点"上执行“包含":参数1不是“节点聚合物"类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆