jQuery 带转义字符的查找函数在最新版本中不起作用

jQuery find function with escape characters not working in latest version

我在查找函数中有一个选择器,它适用于 jQuery 3.3.1,而之前的 3.4.0 和 3.4.1 不适用。我在我使用过 $.parseXML 的 xhtml jQuery 文档对象上使用它。我正在使用 jQuery.

的完整版本

我查看了 jQuery 变更日志,没有发现任何影响此的内容,以及 github 上的源变更。

我已经用 .class 和 #id 测试了查找结果,它有效,但 ID 是动态的,因此我需要按属性名称进行搜索。我还需要操作多个跨度,这就是为什么我需要 .each(function) 的原因。目前我们正在冻结对 jQuery 3.3.1 的依赖,因为它按预期工作,但在 3.4.0+ 中它甚至没有进入功能。

作品:

const xmlDoc = $.parseXML(`<?xml version="1.0" encoding="windows-1252" ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns:dd="DynamicDocumentation">
        <head>
        <title></title>
        </head><body><span dd:drop_list_uuid="9999">mydrop1</span></body></html>`);
const $xml = $(xmlDoc).find('body');
$xml.find('span[dd\:drop_list_uuid]').each(function() { 
  console.log($(this).text())
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

无效:

const xmlDoc = $.parseXML(`<?xml version="1.0" encoding="windows-1252" ?>
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <html xmlns:dd="DynamicDocumentation">
        <head>
        <title></title>
        </head><body><span dd:drop_list_uuid="9999">mydrop1</span></body></html>`);
const $xml = $(xmlDoc).find('body');
$xml.find('span[dd\:drop_list_uuid]').each(function() { // This is the line that doesn't work
  console.log($(this).text())
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

这里问题解决了。 3.4.0+ 消除了嘶嘶声。

https://forum.jquery.com/topic/jquery-find-function-with-escape-characters-not-working-in-latest-version#14737000008103091

“jQuery 的新版本使用了 querySelectoAll 而没有 sizzle。这么多 sizzle 语法不再起作用了。

命名空间属性查询可能很快就实现了。" -杰克雪茄