:scope inside :has() is taken for the :has() element
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- typescript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Start by reading subselects.has, absolutize, and the scope filter to understand how :has() handles its anchor and the query scope. Run the WPT test css/selectors/has-argument-with-explicit-scope.html and compare its results with the examples in the issue; done means all 13 subtests match the expected behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Inside :has(), :scope is still the scope of the query, and the root where the query has none. css-select reads it as something else: the :has() element where the argument has a combinator in it, and the root where it has none, whatever the query's scope.
import { compile } from 'css-select';
import { parseDocument } from 'htmlparser2';
import { findOne } from 'domutils';
const doc = parseDocument(
'<div id="m"><div class="a" id="s"><i class="a" id="i"><b class="b"></b></i></div></div>',
);
const [m, s, i] = ['m', 's', 'i'].map((id) =>
findOne((e) => e.attribs.id === id, doc.children, true),
);
// does `element` match `selector`, in a query whose scope is `scope`
const ask = (selector, scope, element) =>
compile(selector, { xmlMode: false, relativeSelector: false }, scope)(element);
// each line prints the opposite of Chrome 152's answer
console.log(ask(':has(:scope .b)', i, i)); // true
console.log(ask(':has(> :scope)', i, s)); // false
console.log(ask(':has(.a :scope)', i, m)); // false
console.log(ask(':has(:scope)', i, s)); // false
// with no scope, as in a style sheet, `:scope` is the root, which nothing holds
console.log(compile('.a:has(:scope .b)', { xmlMode: false })(s)); // true
WPT has this as css/selectors/has-argument-with-explicit-scope.html.
Cause. subselects.has is handed the query's context as _context and does not use it. With a combinator in the argument it compiles with a [PLACEHOLDER_ELEMENT] context of its own, which it points at each element it is asked of, context[0] = element, and the scope filter reads that. Without one it compiles with no context, which scope reads as :root. An entry that names :scope is also left unanchored, because absolutize skips it by hasScopePseudo, so :has(.a :scope) looks under the element for the element itself and never finds it.
What was tried. Nothing in css-select. :has() needs two things here that it has one context for, the element it anchors at and the query's scope, so a fix probably has to anchor with something other than :scope. For anyone who needs it before a fix, https://github.com/sidorares/react-x11-components/pull/1150 compiles each :scope in a :has() on its own with the query's context and hands it in through pseudos. With that and a workaround for #1928, 80 generated selectors over 6 generated documents, each asked from about a dozen scopes and from the document, answer as Chrome 152 does in all 480 lines of answers, where 192 did without it, and the WPT test above goes from 10 of 13 subtests to 13.
Run on css-select 7.0.0. master at 2b69f6c has the same lines, which I checked by reading it, not by running it.
- Ngôn ngữ chính
- TypeScript
- Star
- 636
- Fork
- 85
- Merge trung bình
- 1 phút
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fb55/css-select
-
:nth-* selectors incorrectly reject detached elements when the formula matches every indexCó thể đã có người làm @bardrop đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
fb55/css-select#1945 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
:is(), :where(), :not() and aliases inside :has() are read as relative to the :has() elementCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
fb55/css-select#1930 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
A descendant combinator after a complex :is() or :not() keeps answers it should notCó thể đã có người làm @Aschenbath đã nhận 12 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
fb55/css-select#1929 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
:has(.a .b) matches with the :has() element itself as .aCó thể đã có người làm @manav4u đã nhận 14 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
fb55/css-select#1928 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Nesting selector supportĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
fb55/css-select#1838 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fb55/css-select
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fb55/htmlparser2#2579 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug good first issue needs-review
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add Module DB RulesĐang mởdocumentation public
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 68/100
midnightntwrk/umbradb#65 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area/channels kind/bug priority/medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nanocoai/nanoclaw#4501 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Docker images: plain X.Y.Z tag (e.g. 7.2.3) is never updated after the initial release buildĐang mởneeds verification
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 13 ngày