Skip to content

fix(lit-html): detect incomplete document mocks for TreeWalker#5365

Open
Hashim1999164 wants to merge 1 commit into
lit:mainfrom
Hashim1999164:fix/lit-html-document-mock-treewalker
Open

fix(lit-html): detect incomplete document mocks for TreeWalker#5365
Hashim1999164 wants to merge 1 commit into
lit:mainfrom
Hashim1999164:fix/lit-html-document-mock-treewalker

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Fixes #4855 by treating a document without createTreeWalker the same as a missing document in Node mode.

Some test environments (for example Stencil Jest) provide a mock document that does not implement createTreeWalker. Lit only installed its TreeWalker stub when document was undefined, so those mocks still threw createTreeWalker is not a function.

Test plan

  • Confirm the condition uses typeof global.document?.createTreeWalker !== 'function'
  • Sanity check that a normal browser/document path is unchanged
  • Existing lit-html CI / unit tests pass

Stencil and similar Jest document mocks define document but omit
createTreeWalker. Check for that method so the Node stub still applies.
Fixes lit#4855
@changeset-bot

changeset-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 494b223

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
lit-html Patch
lit-element Patch
lit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@google-cla

google-cla Bot commented Jul 23, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lit-html] document mock check is too loose

1 participant