没有namespaceURI的文档的Document.evaluate崩溃Microsoft Edge

a55*_*553 5 javascript xml xmldocument microsoft-edge

从Windows 10 build 10240在Microsoft Edge上测试.在构建10586中修复.

概要

XMLDocument.prototype.evaluate在已namespaceURI设置为null崩溃Microsoft Edge中的当前选项卡进程的文档上运行,使该选项卡的开发人员工具无响应,向其发送调试信息watson.telemetry.microsoft.com并强制重新加载页面.

摄制

要重现,请打开Microsoft Edge中的任何网站,按F12打开开发人员工具,选择控制台,然后运行以下3行javascript:

var doc = document.implementation.createDocument(null, null, null);
var node = doc.createElement('A');
doc.evaluate('B', node, doc.createNSResolver(doc), 9, null);
Run Code Online (Sandbox Code Playgroud)

a55*_*553 6

解决方法

baseURI在运行之前访问上下文节点的属性evaluate.

var doc = document.implementation.createDocument(null, null, null);
var node = doc.createElement('A');

node.baseURI; // Edge workaround http://stackoverflow.com/q/33887400/823663

doc.evaluate('B', node, doc.createNSResolver(doc), 9, null);
Run Code Online (Sandbox Code Playgroud)