[Bug]: `html:has(> body)` and `:scope > body` on the `<html>` element match nothing
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ó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 76/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ệ
- playwright, typescript
- Lĩnh vực
- backend, testing-qa
Hướng nghiên cứu
Start in packages/injected/src/selectorEvaluator.ts, especially _matchesSimple and _expandContextForScopeMatching, which the issue identifies as the failing path. Compare the behavior for the root element with the included reproduction and native querySelectorAll. Done means the three reported locators match one element, with regression coverage for root :scope matching.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
1.65.0 (also 1.66.0-alpha-1793916328000)
Steps to reproduce
- Clone https://github.com/trackoor/playwright-css-has-root-repro
npm install && npx playwright install chromiumnpm test
The test:
import { test, expect } from '@playwright/test';
test(':has(> ...) and :scope > ... on the <html> element', async ({ page }) => {
await page.setContent('<body class="dark"><div><p>x</p></div></body>');
// native querySelectorAll finds 1 for each of these
expect(await page.evaluate(() => document.querySelectorAll('html:has(> body)').length)).toBe(1);
await expect(page.locator('html:has(> body)')).toHaveCount(1);
await expect(page.locator(':root:has(> body)')).toHaveCount(1);
await expect(page.locator('html').locator(':scope > body')).toHaveCount(1);
});
Expected behavior
All three locators find the one element, like document.querySelectorAll does for the same selectors.
Actual behavior
All three return 0 elements:
Error: expect(locator).toHaveCount(expected) failed
Locator: locator('html:has(> body)')
Expected: 1
Received: 0
html:has(body) and div:has(> p) work, so only :scope matching on the root element is affected.
Additional context
In packages/injected/src/selectorEvaluator.ts, _matchesSimple refuses element === context.scope and relies on _expandContextForScopeMatching to widen the scope to the parent. For <html>, parentElementOrShadowHost() returns null, so the context is returned unchanged and <html> can never match as :scope. Same code on main at 07c7069.
Environment
System:
OS: Linux (x64)
Binaries:
Node: 26.13.0
npmPackages:
@playwright/test: 1.65.0
Credit: https://ucsbplse.github.io/
- Ngôn ngữ chính
- TypeScript
- Star
- 99.1k
- Fork
- 6.8k
- Merge trung bình
- 17 giờ 6 phút
- Pull request đã merge (30 ngày)
- 306
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 microsoft/playwright
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
microsoft/playwright#43986 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: Embedded number/range inputs contribute their `value` attribute, not their current value, to accessible namesCó thể đã có người làm @lazerg đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
microsoft/playwright#43984 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 64/100
microsoft/playwright#43983 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
microsoft/playwright#43981 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
microsoft/playwright#43969 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/playwright
Issue tương tự
-
FR: Support CJK brackets, symbols and full-width markers in footnoteHeuristics (EBPAJ support)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
readest/readest#7413 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
content triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
eliasstravik/herdr-projects#788 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Ability to edit tagsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày