[Bug]: `html:has(> body)` and `:scope > body` on the `<html>` element match nothing
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- playwright, typescript
- Ambito
- backend, testing-qa
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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/
- Lingua principale
- TypeScript
- Stelle
- 99.1k
- Fork
- 6.8k
- Merge medio
- 17h 6m
- PR unite (30g)
- 306
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/playwright
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
microsoft/playwright#43986 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Embedded number/range inputs contribute their `value` attribute, not their current value, to accessible namesForse già presa @lazerg l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
microsoft/playwright#43984 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 64/100
microsoft/playwright#43983 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
microsoft/playwright#43981 ·
I maintainer di solito rispondono entro 1 giorno
-
needs-triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 30/100
microsoft/playwright#43969 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/playwright
Issue simili
-
FR: Support CJK brackets, symbols and full-width markers in footnoteHeuristics (EBPAJ support)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
readest/readest#7413 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
content triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
eliasstravik/herdr-projects#788 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Ability to edit tagsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno