:has(.a .b) matches with the :has() element itself as .a
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- backend
调研方向
Start in css-select's subselects.has and follow how it calls compileToken with [PLACEHOLDER_ELEMENT]; inspect the _flexibleDescendant condition described in the issue. Reproduce the supplied selector case on css-select 7.0.0, then verify that matching agrees with the expected false result and that relevant tests pass.
由索引模型根据 Issue 内容生成。
描述
The argument of .a:has(.a .b) absolutizes to :scope .a .b, so the .a has to be inside the :has() element. css-select also accepts the element itself.
import { compile } from 'css-select';
import { parseDocument } from 'htmlparser2';
import { findOne } from 'domutils';
const doc = parseDocument('<div class="a" id="t"><i class="b"></i></div>');
const t = findOne((e) => e.attribs.id === 't', doc.children, true);
console.log(compile('.a:has(.a .b)', { xmlMode: false })(t));
// true, where Chrome 152's t.matches('.a:has(.a .b)') is false
Cause. subselects.has passes an array context, [PLACEHOLDER_ELEMENT], so compileToken replaces the descendant combinator after :scope with _flexibleDescendant, which includes the element itself. Its comment says "only used while querying an array", and here the array is only how has swaps the element in.
What was tried. Adding finalContext[0] !== PLACEHOLDER_ELEMENT to that condition, on a copy of 7.0.0, makes the example answer false.
Run on css-select 7.0.0. master at 2b69f6c has the same lines, which I checked by reading it, not by running it.
- 主要语言
- TypeScript
- 星标
- 636
- 派生
- 85
- 平均合并
- 1 分钟
- 30 天内合并 PR
- 13
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fb55/css-select 的其他 Issue
-
:nth-* selectors incorrectly reject detached elements when the formula matches every index可能已有人在做 @bardrop 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
fb55/css-select#1945 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
fb55/css-select#1931 · 1 条评论 ·
维护者通常 1 天内回复
-
:is(), :where(), :not() and aliases inside :has() are read as relative to the :has() element可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 55/100
fb55/css-select#1930 · 1 条评论 ·
维护者通常 1 天内回复
-
A descendant combinator after a complex :is() or :not() keeps answers it should not可能已有人在做 @Aschenbath 于 12 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 48/100
fb55/css-select#1929 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 42/100
fb55/css-select#1838 · 1 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
fb55/htmlparser2#2579 ·
维护者通常 1 天内回复
-
bug good first issue needs-review
难度 1/5 1-3 小时 新手友好度 83/100
维护者通常 1 天内回复
-
documentation public
难度 1/5 1-3 小时 新手友好度 68/100
midnightntwrk/umbradb#65 ·
维护者通常 2 天内回复
-
area/channels kind/bug priority/medium
难度 2/5 1-3 小时 新手友好度 78/100
nanocoai/nanoclaw#4501 · 1 条评论 ·
维护者通常 1 天内回复
-
needs verification
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 13 天内回复