forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1790483 - Vendor the lit library in toolkit/content/widgets r=hjones
lit is a library for building Web Components. It is released under the BSD 3-Clause license. Website: https://lit.dev/ GitHub: https://github.com/lit/lit/ Differential Revision: https://phabricator.services.mozilla.com/D159765
- Loading branch information
Showing
18 changed files
with
4,691 additions
and
288 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
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,52 @@ | ||
From 1f0db62374e62965f521c3a44c31c947f702d53d Mon Sep 17 00:00:00 2001 | ||
From: Mark Striemer <[email protected]> | ||
Date: Wed, 16 Nov 2022 22:54:20 -0600 | ||
Subject: [PATCH 1/2] disable terser step | ||
|
||
--- | ||
rollup-common.js | 8 ++++---- | ||
1 file changed, 4 insertions(+), 4 deletions(-) | ||
|
||
diff --git a/rollup-common.js b/rollup-common.js | ||
index ebe4b406..6fcac21a 100644 | ||
--- a/rollup-common.js | ||
+++ b/rollup-common.js | ||
@@ -345,7 +345,7 @@ export function litProdConfig({ | ||
virtual({ | ||
[nameCacheSeederInfile]: nameCacheSeederContents, | ||
}), | ||
- terser(nameCacheSeederTerserOptions), | ||
+ // terser(nameCacheSeederTerserOptions), | ||
skipBundleOutput, | ||
], | ||
}, | ||
@@ -395,7 +395,7 @@ export function litProdConfig({ | ||
// This plugin automatically composes the existing TypeScript -> raw JS | ||
// sourcemap with the raw JS -> minified JS one that we're generating here. | ||
sourcemaps(), | ||
- terser(terserOptions), | ||
+ // terser(terserOptions), | ||
summary({ | ||
showBrotliSize: true, | ||
showGzippedSize: true, | ||
@@ -466,7 +466,7 @@ export function litProdConfig({ | ||
// references properties from reactive-element which will | ||
// otherwise have different names. The default export that | ||
// lit-element will use is minified. | ||
- terser(terserOptions), | ||
+ // terser(terserOptions), | ||
summary({ | ||
showBrotliSize: true, | ||
showGzippedSize: true, | ||
@@ -533,7 +533,7 @@ const litMonoBundleConfig = ({ | ||
// This plugin automatically composes the existing TypeScript -> raw JS | ||
// sourcemap with the raw JS -> minified JS one that we're generating here. | ||
sourcemaps(), | ||
- terser(terserOptions), | ||
+ // terser(terserOptions), | ||
summary({ | ||
showBrotliSize: true, | ||
showGzippedSize: true, | ||
-- | ||
2.32.0 (Apple Git-132) | ||
|
43 changes: 43 additions & 0 deletions
43
toolkit/content/vendor/lit/0002-use-DOMParser-not-innerHTML.patch
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,43 @@ | ||
From e2fb71a850fda2d1f02a19d41a3db1cd7cf8618d Mon Sep 17 00:00:00 2001 | ||
From: Mark Striemer <[email protected]> | ||
Date: Wed, 16 Nov 2022 23:07:57 -0600 | ||
Subject: [PATCH 2/2] use DOMParser not innerHTML= | ||
|
||
--- | ||
packages/lit-html/src/lit-html.ts | 13 ++++++++++--- | ||
1 file changed, 10 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/packages/lit-html/src/lit-html.ts b/packages/lit-html/src/lit-html.ts | ||
index 51941fdf..13914ca7 100644 | ||
--- a/packages/lit-html/src/lit-html.ts | ||
+++ b/packages/lit-html/src/lit-html.ts | ||
@@ -14,6 +14,8 @@ const NODE_MODE = false; | ||
// Use window for browser builds because IE11 doesn't have globalThis. | ||
const global = NODE_MODE ? globalThis : window; | ||
|
||
+const __moz_domParser = new DOMParser(); | ||
+ | ||
/** | ||
* Contains types that are part of the unstable debug API. | ||
* | ||
@@ -1017,9 +1019,14 @@ class Template { | ||
// Overridden via `litHtmlPolyfillSupport` to provide platform support. | ||
/** @nocollapse */ | ||
static createElement(html: TrustedHTML, _options?: RenderOptions) { | ||
- const el = d.createElement('template'); | ||
- el.innerHTML = html as unknown as string; | ||
- return el; | ||
+ const doc = __moz_domParser.parseFromString( | ||
+ `<template>${html}</template>`, | ||
+ 'text/html' | ||
+ ); | ||
+ return document.importNode( | ||
+ doc.querySelector('template') as HTMLTemplateElement, | ||
+ true | ||
+ ); | ||
} | ||
} | ||
|
||
-- | ||
2.32.0 (Apple Git-132) | ||
|
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,9 @@ | ||
#!/bin/bash | ||
cp *.patch lit/ | ||
cd lit | ||
git apply *.patch | ||
../../../../../mach npm install | ||
../../../../../mach npm run build | ||
cp packages/lit/lit-all.min.js ../../../widgets/vendor/lit.all.mjs | ||
rm -rf * .* | ||
cp ../LICENSE . |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2017 Google LLC. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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 |
---|---|---|
|
@@ -10,5 +10,24 @@ origin: | |
"Lit is a simple library for building fast, lightweight web components." | ||
url: "https://github.com/lit/lit" | ||
license: "BSD-3-Clause" | ||
release: "2.4.0" | ||
revision: "[email protected]" | ||
release: "[email protected]" | ||
revision: "1e1e2e00e3ff655e6f48a42b2e739f47dc681420" | ||
|
||
|
||
# Since this tracks the latest tag, it's possible that lit isn't the latest tag | ||
# in lit/lit. In that case we may need to manually update lit. See README.md for | ||
# more info. | ||
vendoring: | ||
url: "https://github.com/lit/lit" | ||
source-hosting: github | ||
tracking: tag | ||
# lit/lit is a monorepo that publishes multiple packages. The tags for lit | ||
# are formatted as "[email protected]". | ||
# tag-prefix: 'lit@' | ||
|
||
vendor-directory: toolkit/content/vendor/lit/lit | ||
|
||
update-actions: | ||
- action: run-script | ||
script: '{yaml_dir}/bundle-lit.sh' | ||
cwd: '{yaml_dir}' |
Oops, something went wrong.