Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[reactive-element] Fix Node build auto-shimming of
HTMLElement
to r…
…espect existing global shim (#3561) * Update rollup plugin-replace * Add changesets * Add tests for dom shim * Update .changeset/tidy-lamps-rest.md Co-authored-by: Alexander Marks <aomarks@google.com> Co-authored-by: Alexander Marks <aomarks@google.com>
- Loading branch information
Showing
11 changed files
with
175 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@lit/lit-starter-js': patch | ||
'@lit/lit-starter-ts': patch | ||
--- | ||
|
||
Update dependency `@rollup/plugin-replace` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'lit': patch | ||
'@lit/reactive-element': patch | ||
--- | ||
|
||
Fix built-in shimming of `HTMLElement` for Node build of `reactive-element` to respect existing `HTMLElement` in global |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
// This file will be loaded by Node from the node:test-dom-shim script to verify | ||
// `ReactiveElement` will prefer extending existing `HTMLElement` from the | ||
// global rather than the built-in shim | ||
|
||
import './node-shim-html-element.js'; | ||
import {ReactiveElement} from '@lit/reactive-element'; | ||
import {HTMLElement} from '@lit-labs/ssr-dom-shim'; | ||
|
||
import assert from 'node:assert/strict'; | ||
assert.strictEqual( | ||
Object.getPrototypeOf(ReactiveElement), | ||
globalThis.HTMLElement, | ||
'Expected ReactiveElement to extend existing globalThis.HTMLElement' | ||
); | ||
assert.notStrictEqual( | ||
Object.getPrototypeOf(ReactiveElement), | ||
HTMLElement, | ||
'Expected ReactiveElement to not extend HTMLElement from ssr-dom-shim' | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/reactive-element/src/test/node-shim-html-element.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
// This file is used as a side-effectful import in `node-dom-shim.js` to | ||
// simulate loading a separate DOM shim that adds `HTMLElement` to the global | ||
|
||
class FakeHTMLElement {} | ||
globalThis.HTMLElement = FakeHTMLElement as typeof HTMLElement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters