Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

某些使用场景下,document.querySelector 不需要被替换为了shadowRoot.querySelector #262

Closed
jardenliu opened this issue Nov 16, 2022 · 1 comment

Comments

@jardenliu
Copy link
Contributor

描述bug
在接入使用了 DOMPurify (版本号2.3.0)库的子应用时,出现了一些诡异的现象,sanitize的结果居然是shadowRoot的body的html。查看源码后发现是document.getElementsByTagName 在wujie中被patch为了shadowRoot的getElementsByTagName, 当_ctx为

如何复现
给出详细的复现步骤
1、可以在 https://wujie-micro.github.io/doc/wujie/ 中在线加载 https://www.jarden.vip/wujie-demo/demo4.html
2、 观察控制台输出
3、 demo的简化版源码放楼下了

错误截图
1668603650364

最小复现仓库或者地址
https://www.jarden.vip/wujie-demo/demo4.html

@jardenliu
Copy link
Contributor Author

const doc = new DOMParser().parseFromString('<div id="test"></div>', 'text/html')
console.log("doc:", doc)
console.log("document.querySelector.call test:", document.querySelector.call(doc, "#test"))
console.log("doc.querySelector test2:", doc.querySelector("#test"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant