Merge pull request #45 from PolymerLabs/update-lit-next

update-lit-next
This commit is contained in:
Peter Burns
2021-04-21 11:58:14 -07:00
committed by GitHub
17 changed files with 19330 additions and 8389 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
/node_modules/ node_modules/
/lib/ /lib/
/test/ /test/
custom-elements.json custom-elements.json

20
LICENSE
View File

@@ -1,20 +1,20 @@
BSD 3-Clause License BSD 3-Clause License
Copyright (c) 2019, The Polymer Authors. All rights reserved. Copyright (c) 2019 Google LLC. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met: modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this 1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer. list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, 2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution. and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its 3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from contributors may be used to endorse or promote products derived from
this software without specific prior written permission. this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -25,4 +25,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 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 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. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -1,3 +1,9 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const fs = require('fs'); const fs = require('fs');
module.exports = () => { module.exports = () => {

View File

@@ -34,14 +34,14 @@
<nav class="collection"> <nav class="collection">
<ul> <ul>
<li class=selected>
<a href="">A basic example</a>
</li>
<li class=> <li class=>
<a href="name-property/">Setting the name property</a> <a href="name-property/">Setting the name property</a>
</li> </li>
<li class=selected>
<a href="">A basic example</a>
</li>
</ul> </ul>
</nav> </nav>
<div> <div>

View File

@@ -34,20 +34,20 @@
<nav class="collection"> <nav class="collection">
<ul> <ul>
<li class=>
<a href="../">A basic example</a>
</li>
<li class=selected> <li class=selected>
<a href="">Setting the name property</a> <a href="">Setting the name property</a>
</li> </li>
<li class=>
<a href="../">A basic example</a>
</li>
</ul> </ul>
</nav> </nav>
<div> <div>
<p><my-element name="Earth"></my-element></p> <p><my-element name="Earth"></my-element></p>
<h3>HTML</h3> <h3>HTML</h3>
<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>my-element</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Earth<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>my-element</span><span class="token punctuation">></span></span></code></pre> <pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>my-element</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>Earth<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>my-element</span><span class="token punctuation">></span></span></code></pre>
</div> </div>
</section> </section>

View File

@@ -44,7 +44,7 @@
<section class="columns"> <section class="columns">
<div> <div>
<p><code>&lt;my-element&gt;</code> can be configured with attributed in plain HTML.</p> <p><code>&lt;my-element&gt;</code> can be configured with attributed in plain HTML.</p>
<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>my-element</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>HTML<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>my-element</span><span class="token punctuation">></span></span></code></pre> <pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>my-element</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>HTML<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>my-element</span><span class="token punctuation">></span></span></code></pre>
</div> </div>
<div> <div>
<p><my-element name="HTML"></my-element></p> <p><my-element name="HTML"></my-element></p>

View File

@@ -36,7 +36,7 @@
<p>npm CDNs like <a href="">unpkg.com</a> can directly serve files that have been published to npm. This works great for standard JavaScript modules that the browser can load natively.</p> <p>npm CDNs like <a href="">unpkg.com</a> can directly serve files that have been published to npm. This works great for standard JavaScript modules that the browser can load natively.</p>
<p>For this element to work from unpkg.com specifically, you need to include the <code>?module</code> query parameter, which tells unpkg.com to rewrite &quot;bare&quot; module specificers to full URLs.</p> <p>For this element to work from unpkg.com specifically, you need to include the <code>?module</code> query parameter, which tells unpkg.com to rewrite &quot;bare&quot; module specificers to full URLs.</p>
<h3>HTML</h3> <h3>HTML</h3>
<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>module<span class="token punctuation">"</span></span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>https://unpkg.com/my-element?module<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre> <pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>module<span class="token punctuation">"</span></span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>https://unpkg.com/my-element?module<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre>
<h3>JavaScript</h3> <h3>JavaScript</h3>
<pre class="language-html"><code class="language-html">import {MyElement} from 'https://unpkg.com/my-element?module';</code></pre> <pre class="language-html"><code class="language-html">import {MyElement} from 'https://unpkg.com/my-element?module';</code></pre>

Binary file not shown.

View File

@@ -52,7 +52,7 @@ pre[class*="language-"] {
.token.prolog, .token.prolog,
.token.doctype, .token.doctype,
.token.cdata { .token.cdata {
color: slategray; color: #8292a2;
} }
.token.punctuation { .token.punctuation {

27506
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -33,18 +33,17 @@
"typescript", "typescript",
"lit" "lit"
], ],
"author": "The Polymer Authors", "author": "Google LLC",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"dependencies": { "dependencies": {
"lit": "^2.0.0-pre.1", "lit": "^2.0.0-rc.1"
"lit-element": "^3.0.0-pre.2"
}, },
"devDependencies": { "devDependencies": {
"@11ty/eleventy": "^0.10.0", "@11ty/eleventy": "^0.12.1",
"@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1", "@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1",
"@esm-bundle/chai": "^4.1.5", "@esm-bundle/chai": "^4.1.5",
"@open-wc/testing": "^2.5.32", "@open-wc/testing": "^2.5.32",
"@open-wc/testing-karma": "^3.3.11", "@open-wc/testing-karma": "^4.0.9",
"@rollup/plugin-node-resolve": "^9.0.0", "@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.3", "@rollup/plugin-replace": "^2.3.3",
"@types/mocha": "^7.0.2", "@types/mocha": "^7.0.2",
@@ -53,9 +52,9 @@
"@web/dev-server": "0.0.29", "@web/dev-server": "0.0.29",
"@web/dev-server-legacy": "^0.1.4", "@web/dev-server-legacy": "^0.1.4",
"@web/dev-server-rollup": "^0.2.7", "@web/dev-server-rollup": "^0.2.7",
"@web/test-runner": "^0.10.2", "@web/test-runner": "^0.12.15",
"@web/test-runner-mocha": "^0.3.5", "@web/test-runner-mocha": "^0.3.5",
"@web/test-runner-playwright": "^0.5.7", "@web/test-runner-playwright": "^0.8.4",
"@webcomponents/webcomponentsjs": "^2.5.0", "@webcomponents/webcomponentsjs": "^2.5.0",
"deepmerge": "^4.2.2", "deepmerge": "^4.2.2",
"eslint": "^6.8.0", "eslint": "^6.8.0",

View File

@@ -1,15 +1,7 @@
/** /**
* @license * @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved. * Copyright 2018 Google LLC
* This code may only be used under the BSD style license found at * SPDX-License-Identifier: BSD-3-Clause
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/ */
import summary from 'rollup-plugin-summary'; import summary from 'rollup-plugin-summary';

View File

@@ -1,19 +1,11 @@
/** /**
* @license * @license
* Copyright (c) 2019 The Polymer Project Authors. All rights reserved. * Copyright 2019 Google LLC
* This code may only be used under the BSD style license found at * SPDX-License-Identifier: BSD-3-Clause
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/ */
import {LitElement, html, css} from 'lit'; import {LitElement, html, css} from 'lit';
import {customElement, property} from 'lit/decorators'; import {customElement, property} from 'lit/decorators.js';
/** /**
* An example element. * An example element.

View File

@@ -1,3 +1,9 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import {MyElement} from '../my-element.js'; import {MyElement} from '../my-element.js';
import {fixture, html} from '@open-wc/testing'; import {fixture, html} from '@open-wc/testing';
@@ -48,4 +54,10 @@ suite('my-element', () => {
` `
); );
}); });
test('styling applied', async () => {
const el = (await fixture(html`<my-element></my-element>`)) as MyElement;
await el.updateComplete;
assert.equal(getComputedStyle(el).paddingTop, '16px');
});
}); });

View File

@@ -1,6 +1,6 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es2020", "target": "es2019",
"module": "es2020", "module": "es2020",
"lib": ["es2020", "DOM", "DOM.Iterable"], "lib": ["es2020", "DOM", "DOM.Iterable"],
"declaration": true, "declaration": true,

View File

@@ -1,3 +1,9 @@
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import {legacyPlugin} from '@web/dev-server-legacy'; import {legacyPlugin} from '@web/dev-server-legacy';
export default { export default {

View File

@@ -1,13 +1,86 @@
import {playwrightLauncher} from '@web/test-runner-playwright'; /**
import {legacyPlugin} from '@web/dev-server-legacy'; * @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
import {legacyPlugin} from '@web/dev-server-legacy';
import {playwrightLauncher} from '@web/test-runner-playwright';
// Uncomment for testing on Sauce Labs
// Must run `npm i --save-dev @web/test-runner-saucelabs` and set
// SAUCE_USERNAME and SAUCE_USERNAME environment variables
// ===========
// import {createSauceLabsLauncher} from '@web/test-runner-saucelabs';
// const sauceLabsLauncher = createSauceLabsLauncher(
// {
// user: process.env.SAUCE_USERNAME,
// key: process.env.SAUCE_USERNAME,
// },
// {
// 'sauce:options': {
// name: 'unit tests',
// build: `${process.env.GITHUB_REF ?? 'local'} build ${
// process.env.GITHUB_RUN_NUMBER ?? ''
// }`,
// },
// }
// );
// Uncomment for testing on BrowserStack
// Must run `npm i --save-dev @web/test-runner-browserstack` and set
// BROWSER_STACK_USERNAME and BROWSER_STACK_ACCESS_KEY environment variables
// ===========
// import {browserstackLauncher as createBrowserstackLauncher} from '@web/test-runner-browserstack';
// const browserstackLauncher = (config) => createBrowserstackLauncher({
// capabilities: {
// 'browserstack.user': process.env.BROWSER_STACK_USERNAME,
// 'browserstack.key': process.env.BROWSER_STACK_ACCESS_KEY,
// project: 'my-element',
// name: 'unit tests',
// build: `${process.env.GITHUB_REF ?? 'local'} build ${
// process.env.GITHUB_RUN_NUMBER ?? ''
// }`,
// ...config,
// }
// });
const browsers = {
// Local browser testing via playwright
// ===========
chromium: playwrightLauncher({product: 'chromium'}),
firefox: playwrightLauncher({product: 'firefox'}),
webkit: playwrightLauncher({product: 'webkit'}),
// Uncomment example launchers for running on Sauce Labs
// ===========
// chromium: sauceLabsLauncher({browserName: 'chrome', browserVersion: 'latest', platformName: 'Windows 10'}),
// firefox: sauceLabsLauncher({browserName: 'firefox', browserVersion: 'latest', platformName: 'Windows 10'}),
// edge: sauceLabsLauncher({browserName: 'MicrosoftEdge', browserVersion: 'latest', platformName: 'Windows 10'}),
// ie11: sauceLabsLauncher({browserName: 'internet explorer', browserVersion: '11.0', platformName: 'Windows 10'}),
// safari: sauceLabsLauncher({browserName: 'safari', browserVersion: 'latest', platformName: 'macOS 10.15'}),
// Uncomment example launchers for running on Sauce Labs
// ===========
// chromium: browserstackLauncher({browserName: 'Chrome', os: 'Windows', os_version: '10'}),
// firefox: browserstackLauncher({browserName: 'Firefox', os: 'Windows', os_version: '10'}),
// edge: browserstackLauncher({browserName: 'MicrosoftEdge', os: 'Windows', os_version: '10'}),
// ie11: browserstackLauncher({browserName: 'IE', browser_version: '11.0', os: 'Windows', os_version: '10'}),
// safari: browserstackLauncher({browserName: 'Safari', browser_version: '14.0', os: 'OS X', os_version: 'Big Sur'}),
};
// Prepend BROWSERS=x,y to `npm run test` to run a subset of browsers
// e.g. `BROWSERS=chromium,firefox npm run test`
const noBrowser = (b) => {
throw new Error(`No browser configured named '${b}'; using defaults`);
};
let commandLineBrowsers; let commandLineBrowsers;
try { try {
commandLineBrowsers = process.env.BROWSERS?.split(',').map((b) => commandLineBrowsers = process.env.BROWSERS?.split(',').map(
playwrightLauncher({product: b}) (b) => browsers[b] ?? noBrowser(b)
); );
} catch { } catch (e) {
console.warn(`BROWSER ${process.env.BROWSERS} unknown; using defaults`); console.warn(e);
} }
// https://modern-web.dev/docs/test-runner/cli-and-configuration/ // https://modern-web.dev/docs/test-runner/cli-and-configuration/
@@ -16,11 +89,7 @@ export default {
files: ['./test/**/*_test.js'], files: ['./test/**/*_test.js'],
nodeResolve: true, nodeResolve: true,
preserveSymlinks: true, preserveSymlinks: true,
browsers: commandLineBrowsers ?? [ browsers: commandLineBrowsers ?? Object.values(browsers),
playwrightLauncher({product: 'chromium'}),
playwrightLauncher({product: 'firefox'}),
playwrightLauncher({product: 'webkit'}),
],
testFramework: { testFramework: {
// https://mochajs.org/api/mocha // https://mochajs.org/api/mocha
config: { config: {
@@ -33,6 +102,17 @@ export default {
legacyPlugin({ legacyPlugin({
polyfills: { polyfills: {
webcomponents: true, webcomponents: true,
// Inject lit's polyfill-support module into test files, which is required
// for interfacing with the webcomponents polyfills
custom: [
{
name: 'lit-polyfill-support',
path: 'node_modules/lit/polyfill-support.js',
test:
"!('attachShadow' in Element.prototype) || !('getRootNode' in Element.prototype) || window.ShadyDOM && window.ShadyDOM.force",
module: false,
},
],
}, },
}), }),
], ],