From 0653692a5b844eef02143823508befb0e1e1a2b0 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Tue, 25 Oct 2022 14:31:39 -0700 Subject: [PATCH] fix(selectors): `:scope` combined with other css should work (#18324) Previously, we considered root when selector has `:scope` modifier, but did not actually match it with other css specifiers, like in `:scope.selected`. Fixes #17824. --- .../playwright-core/src/server/injected/selectorEvaluator.ts | 2 +- tests/page/selectors-css.spec.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/playwright-core/src/server/injected/selectorEvaluator.ts b/packages/playwright-core/src/server/injected/selectorEvaluator.ts index 1941482757..abe0566249 100644 --- a/packages/playwright-core/src/server/injected/selectorEvaluator.ts +++ b/packages/playwright-core/src/server/injected/selectorEvaluator.ts @@ -206,7 +206,7 @@ export class SelectorEvaluatorImpl implements SelectorEvaluator { if (css !== undefined) { elements = this._queryCSS(context, css); const hasScopeClause = funcs.some(f => f.name === 'scope'); - if (hasScopeClause && context.scope.nodeType === 1 /* Node.ELEMENT_NODE */) + if (hasScopeClause && context.scope.nodeType === 1 /* Node.ELEMENT_NODE */ && this._matchesCSS(context.scope as Element, css)) elements.unshift(context.scope as Element); } else { firstIndex = funcs.findIndex(func => this._getEngine(func.name).query !== undefined); diff --git a/tests/page/selectors-css.spec.ts b/tests/page/selectors-css.spec.ts index bc5e59e38f..8f40f497f6 100644 --- a/tests/page/selectors-css.spec.ts +++ b/tests/page/selectors-css.spec.ts @@ -394,7 +394,6 @@ it('should work with :scope', async ({ page, server }) => { it('should work with :scope and class', async ({ page }) => { it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/17824' }); - it.fixme(); await page.setContent(`
`); const apples = page.locator('.apple');