getElementsByClassName returns nothing for multiple or space-padded class names
维护者通常 5 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
- 领域
- web-dev
调研方向
issue 指向 esm/mixin/parent-node.js,其中 getElementsByClassName 将未拆分的参数传给 classList.has。先阅读该方法及相关测试,然后将其行为与 DOM 规范关于 ASCII 空白和必须包含所有类的要求进行比较。补充覆盖多个类名、顺序相反和前后空格的测试;四个示例都各返回一个匹配项时即为完成。
由索引模型根据 Issue 内容生成。
描述
getElementsByClassName matches the whole argument as a single class, so "a b", "b a" or " a " find nothing.
const { parseHTML } = require("linkedom");
const { document } = parseHTML('<!doctype html><html><body><p class="a b">x</p></body></html>');
console.log(
document.getElementsByClassName("a").length,
document.getElementsByClassName("a b").length,
document.getElementsByClassName("b a").length,
document.getElementsByClassName(" a ").length
);
node t.js
Expected: 1 1 1 1
Actual: 1 0 0 0
Tested with linkedom 0.18.15 from npm and main at 6e2ae0c, Node.js 26.13.0.
The DOM spec splits the argument on ASCII whitespace and requires all classes (https://dom.spec.whatwg.org/#concept-getelementsbyclassname). getElementsByClassName in esm/mixin/parent-node.js calls classList.has(className) with the unsplit string.
Credit: https://ucsbplse.github.io/
- 主要语言
- HTML
- 星标
- 2.1k
- 派生
- 117
- 平均合并
- 4 天 13 小时
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
WebReflection/linkedom 的其他 Issue
-
Parsing splits one text run into several Text nodes at each character reference (`<p>a & b</p>` gives 3 child nodes)可能已有人在做 @johnhldiver-beep 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 68/100
WebReflection/linkedom#353 · 1 条评论 ·
维护者通常 5 天内回复
-
SVG elements in an HTML document report an upper-cased tagName ("PATH" instead of "path")可能已有人在做 @jonasporto 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 85/100
WebReflection/linkedom#344 · 1 条评论 ·
维护者通常 5 天内回复
-
`TextElement.toString()` puts the element text back at the first `><` of the start tag, so an attribute value containing `><` swallows the text of `<style>`, `<script>`, `<title>` and `<textarea>`可能已有人在做 @vsolano9 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
WebReflection/linkedom#341 · 1 条评论 ·
维护者通常 5 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
WebReflection/linkedom#340 · 1 条评论 ·
维护者通常 5 天内回复
-
Element#matches() compiles the selector on every call可能已有人在做 @jonasporto 于 22 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
WebReflection/linkedom#348 · 1 条评论 ·
维护者通常 5 天内回复
查看 WebReflection/linkedom 的全部 Issue
相似的 Issue
-
bug implicit-state
难度 2/5 1-3 小时 新手友好度 76/100
-
v6: OTP input keeps the rest of a selection when you type over it可能已有人在做 @thejesh23 今天认领。 未关闭bug confirmed has-pr js v6
难度 2/5 1-3 小时 新手友好度 82/100
twbs/bootstrap#43323 · 1 条评论 ·
维护者通常 1 天内回复
-
book-layout.spec fails when the similar-books rail holds other projects' books可能已有人在做 @praetorianer777 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
praetorianer777/GoTome#373 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复