[Bug]: Strict mode violation fails with `TypeError: Cannot read properties of undefined (reading 'includes')` for an element inside a slotted web component
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 4/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 54/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- playwright, typescript
- 領域
- frontend, testing-qa
調査の方向性
Start in Playwright’s selector generation code around generateSelector, cssFallback, and makeStrict, identified by the stack trace; inspect the CSS selector engine behavior for shadow root and slotted elements. Reproduce with the linked minimal repository and run its npm test case. Done when the click reports a strict mode violation listing both matching elements instead of throwing a TypeError.
索引モデルが issue の本文から書いたものです。
説明
Version
1.64.1
Steps to reproduce
- Clone https://github.com/triglian/playwright-strict-mode-slot-repro
npm installnpx playwright install chromiumnpm test- The test
bug: the strict mode violation fails with a TypeErrorfails. The click's error isTypeError: Cannot read properties of undefined (reading 'includes')instead of a strict mode violation. The twocontrol:tests pass. Each control removes one condition the bug needs.
Expected behavior
The click fails with a strict mode violation that lists both matching elements, as it does in the two control tests.
Actual behavior
The click fails with a TypeError. The error does not say that the locator matched more than one element.
Error: locator.click: TypeError: Cannot read properties of undefined (reading 'includes')
at parseSelectorString (<anonymous>:2004:17)
at parseSelector (<anonymous>:1884:25)
at InjectedScript.parseSelector (<anonymous>:7104:20)
at makeStrict (<anonymous>:6312:43)
at cssFallback (<anonymous>:6356:10)
at generateSelectorFor (<anonymous>:6160:121)
at generateSelector (<anonymous>:6092:22)
at InjectedScript.generateSelectorSimple (<anonymous>:7115:12)
Additional context
The page structure is in the repository's README.
Found with a design system whose dropdown item renders its own list item in its shadow root and also slots in the list item the app passes. Both have the same classes and inner markup.
The strict mode violation message needs a selector for the parent of the second match (div.k). Its tag-name candidate is rejected (more than five divs before it), so cssFallback runs. cssFallback tells siblings apart with parentNode.children and querySelectorAll, which see only the light DOM children of x-host. The CSS engine's > also matches children of x-host's shadow root. So every path it tries finds the div.k in x-host's own x-item first, and the last line, return makeStrict(uniqueCSSSelector()!), calls parseSelector(undefined).
The same line threw this error in #13652 and #33922, from other causes. #34030 fixed the iframe case only.
Environment
System:
OS: macOS 26.3
CPU: (10) arm64 Apple M1 Max
Memory: 7.38 GB / 64.00 GB
Binaries:
Node: 22.16.0 - ~/.local/share/mise/shims/node
Yarn: 3.5.1 - ~/.local/share/mise/shims/yarn
npm: 10.9.2 - ~/.local/share/mise/shims/npm
pnpm: 8.10.0 - ~/.local/share/mise/shims/pnpm
IDEs:
VSCode: 1.143.1 - /usr/local/bin/code
Cursor: 2.0.34 - /usr/local/bin/cursor
Claude Code: 2.1.312 - ~/.local/bin/claude
Languages:
Bash: 5.2.37 - /opt/homebrew/bin/bash
npmPackages:
@playwright/test: 1.64.1 => 1.64.1
- 主要言語
- TypeScript
- スター
- 98.5k
- フォーク
- 6.7k
- 平均マージ
- 16時間 10分
- マージ済み PR(30日)
- 305
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/playwright のほかの issue
-
[Bug]: Uncaught TypeError in captureSecurityDetails when APIRequestContext reuses a destroyed keep-alive socket対応中かも @microsoft-playwright-automation が今日担当しました。 オープンneeds-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/playwright#43728 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
[Feature]: Set `this.name` in `TargetClosedError` constructor再び着手できるかも @LeonxLJX が 55 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンP3-collecting-feedback
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
microsoft/playwright#42522 · コメント 7 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
microsoft/playwright#43738 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 42/100
microsoft/playwright#43715 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
microsoft/playwright#43711 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
microsoft/playwright の issue をすべて見る
似ている issue
-
bug ui-dashboard
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 91/100
caelestia-dots/caelestia#534 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: scripts bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
tdk-landscape/tdk-cli-core#2706 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
bobadilla-tech/biasmarket.com#402 ·
メンテナーはふだん 1 日以内に返信
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
javvadivijayprasad/sel2pw#28 ·