getAttribute("class") trims the value and returns "" when absent
维护者通常 17 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 68/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
- 领域
- backend
调研方向
Start by tracing getAttribute("class") and class selector matching in linkedom, then run the reproduction with the supplied HTML and compare the results with the stated browser expectations. Done means the class value preserves its leading space, a missing class returns null, and [class^=" a"] matches the element.
由索引模型根据 Issue 内容生成。
描述
issue:
getAttribute("class") should return the attribute exactly as written. linkedom strips the whitespace (" ab" → "ab") and returns "" instead of null when there is no class. Selectors see the stripped value too, so [class^=" a"] misses.
repro:
import { parseHTML } from "linkedom";
const { document } = parseHTML('<html><body><i class=" ab"></i><b></b></body></html>');
const [i, b] = document.body.children;
console.log(JSON.stringify(i.getAttribute("class"))); // "ab"
console.log(JSON.stringify(b.getAttribute("class"))); // ""
console.log(document.querySelectorAll('[class^=" a"]').length); // 0
expected:
" ab", null, 1 (as Chrome, Firefox, Safari)
system:
linkedom 0.18.13, Node 25.8.1
macOS 27.0, arm64
- 主要语言
- HTML
- 星标
- 2.1k
- 派生
- 110
- 平均合并
- 11 天 1 小时
- 30 天内合并 PR
- 1
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
WebReflection/linkedom 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
WebReflection/linkedom#344 ·
维护者通常 17 天内回复
-
`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 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
WebReflection/linkedom#341 ·
维护者通常 17 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
WebReflection/linkedom#340 ·
维护者通常 17 天内回复
-
Element#matches() compiles the selector on every call可能已有人在做 @jonasporto 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
WebReflection/linkedom#348 ·
维护者通常 17 天内回复
-
难度 3/5 半天 新手友好度 50/100
WebReflection/linkedom#345 ·
维护者通常 17 天内回复
查看 WebReflection/linkedom 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
`/search.json` ignores the documented `editions.sort` parameter可能已有人在做 @PranavD2905 今天认领。 未关闭Affects: Server Good First Issue Module: Solr Needs: Triage Theme: Public APIs Theme: Search
难度 2/5 1-3 小时 新手友好度 74/100
internetarchive/openlibrary#13989 · 1 条评论 ·
维护者通常 1 天内回复
-
bug P2: misleading query
难度 2/5 1-3 小时 新手友好度 62/100
jeffknupp/association#478 ·
-
backend bug difficulty: medium priority: medium reliability
难度 2/5 1-3 小时 新手友好度 76/100
trustflow-protocol/trustflow-backend#730 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
firecrawl/firecrawl-mcp-server#548 ·
维护者通常 1 天内回复