Merge pull request #47 from PolymerLabs/lit-next
Merge lit-next into master
This commit is contained in:
@@ -2,8 +2,12 @@ const syntaxHighlight = require('@11ty/eleventy-plugin-syntaxhighlight');
|
||||
|
||||
module.exports = function (eleventyConfig) {
|
||||
eleventyConfig.addPlugin(syntaxHighlight);
|
||||
eleventyConfig.addPassthroughCopy("docs-src/docs.css");
|
||||
eleventyConfig.addPassthroughCopy("docs-src/.nojekyll");
|
||||
eleventyConfig.addPassthroughCopy('docs-src/docs.css');
|
||||
eleventyConfig.addPassthroughCopy('docs-src/.nojekyll');
|
||||
eleventyConfig.addPassthroughCopy(
|
||||
'node_modules/@webcomponents/webcomponentsjs'
|
||||
);
|
||||
eleventyConfig.addPassthroughCopy('node_modules/lit/polyfill-support.js');
|
||||
return {
|
||||
dir: {
|
||||
input: 'docs-src',
|
||||
|
||||
5
.eslintignore
Normal file
5
.eslintignore
Normal file
@@ -0,0 +1,5 @@
|
||||
node_modules/*
|
||||
docs/*
|
||||
docs-src/*
|
||||
rollup-config.js
|
||||
custom-elements.json
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
@@ -10,17 +11,41 @@
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"env": {
|
||||
"browser": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unexpected-multiline": "off",
|
||||
"@typescript-eslint/indent": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"@typescript-eslint/ban-types": "off",
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-empty-function": "off",
|
||||
"@typescript-eslint/no-non-null-assertion": "off",
|
||||
"@typescript-eslint/no-use-before-define": "off",
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"warn",
|
||||
{
|
||||
"argsIgnorePattern": "^_"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["rollup.config.js", "web-test-runner.config.js"],
|
||||
"env": {
|
||||
"node": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": [
|
||||
"*_test.ts",
|
||||
"**/custom_typings/*.ts",
|
||||
"packages/lit-ssr/src/test/integration/tests/**",
|
||||
"packages/lit-ssr/src/lib/util/parse5-utils.ts"
|
||||
],
|
||||
"rules": {
|
||||
"@typescript-eslint/no-explicit-any": "off"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,7 +1,7 @@
|
||||
/node_modules/
|
||||
node_modules/
|
||||
/lib/
|
||||
/test/
|
||||
|
||||
custom-elements.json
|
||||
# top level source
|
||||
my-element.js
|
||||
my-element.js.map
|
||||
|
||||
16
.vscode/extensions.json
vendored
16
.vscode/extensions.json
vendored
@@ -1,13 +1,9 @@
|
||||
{
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
||||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
|
||||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
|
||||
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": [
|
||||
"runem.lit-plugin"
|
||||
],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": [
|
||||
|
||||
]
|
||||
// List of extensions which should be recommended for users of this workspace.
|
||||
"recommendations": ["runem.lit-plugin"],
|
||||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
|
||||
"unwantedRecommendations": []
|
||||
}
|
||||
|
||||
20
LICENSE
20
LICENSE
@@ -1,20 +1,20 @@
|
||||
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
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* 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.
|
||||
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.
|
||||
|
||||
* 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.
|
||||
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
|
||||
@@ -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
|
||||
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.
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
29
README.md
29
README.md
@@ -1,4 +1,4 @@
|
||||
# LitElement TypeScript starter
|
||||
# LitElement TypeScript starter
|
||||
|
||||
This project includes a sample component using LitElement with TypeScript.
|
||||
|
||||
@@ -30,7 +30,11 @@ Both the TypeScript compiler and lit-analyzer are configured to be very strict.
|
||||
|
||||
## Testing
|
||||
|
||||
This sample uses Karma, Chai, Mocha, and the open-wc test helpers for testing. See the [open-wc testing documentation](https://open-wc.org/testing/testing.html) for more information.
|
||||
This sample modern-web.dev's
|
||||
[@web/test-runner](https://www.npmjs.com/package/@web/test-runner) along with
|
||||
Mocha, Chai, and some related helpers for testing. See the
|
||||
[modern-web.dev testing documentation](https://modern-web.dev/docs/test-runner/overview) for
|
||||
more information.
|
||||
|
||||
Tests can be run with the `test` script:
|
||||
|
||||
@@ -40,7 +44,7 @@ npm test
|
||||
|
||||
## Dev Server
|
||||
|
||||
This sample uses open-wc's [es-dev-server](https://github.com/open-wc/open-wc/tree/master/packages/es-dev-server) for previewing the project without additional build steps. ES dev server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers.
|
||||
This sample uses modern-web.dev's [@web/dev-server](https://www.npmjs.com/package/@web/dev-server) for previewing the project without additional build steps. Web Dev Server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers. See [modern-web.dev's Web Dev Server documentation](https://modern-web.dev/docs/dev-server/overview/) for more information.
|
||||
|
||||
To run the dev server and open the project in a new browser tab:
|
||||
|
||||
@@ -53,15 +57,16 @@ There is a development HTML file located at `/dev/index.html` that you can view
|
||||
## Editing
|
||||
|
||||
If you use VS Code, we highly reccomend the [lit-plugin extension](https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin), which enables some extremely useful features for lit-html templates:
|
||||
- Syntax highlighting
|
||||
- Type-checking
|
||||
- Code completion
|
||||
- Hover-over docs
|
||||
- Jump to definition
|
||||
- Linting
|
||||
- Quick Fixes
|
||||
|
||||
The project is setup to reccomend lit-plugin to VS Code users if they don't already have it installed.
|
||||
|
||||
- Syntax highlighting
|
||||
- Type-checking
|
||||
- Code completion
|
||||
- Hover-over docs
|
||||
- Jump to definition
|
||||
- Linting
|
||||
- Quick Fixes
|
||||
|
||||
The project is setup to reccomend lit-plugin to VS Code users if they don't already have it installed.
|
||||
|
||||
## Linting
|
||||
|
||||
|
||||
@@ -33,6 +33,24 @@
|
||||
"description": "The number of times the button has been clicked.",
|
||||
"type": "number",
|
||||
"default": "0"
|
||||
},
|
||||
{
|
||||
"name": "renderRoot",
|
||||
"description": "Node or ShadowRoot into which element DOM should be rendered. Defaults\nto an open shadowRoot.",
|
||||
"type": "HTMLElement | ShadowRoot"
|
||||
},
|
||||
{
|
||||
"name": "isUpdatePending",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "hasUpdated",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"name": "updateComplete",
|
||||
"description": "Returns a Promise that resolves when the element has completed updating.\nThe Promise value is a boolean that is `true` if the element completed the\nupdate without triggering another update. The Promise result is `false` if\na property was set inside `updated()`. If the Promise is rejected, an\nexception was thrown during the update.\n\nTo await additional asynchronous work, override the `getUpdateComplete`\nmethod. For example, it is sometimes useful to await a rendered element\nbefore fulfilling this Promise. To do this, first await\n`super.getUpdateComplete()`, then any subsequent state.",
|
||||
"type": "Promise<boolean>"
|
||||
}
|
||||
],
|
||||
"slots": [
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
|
||||
This directory contains HTML files containing your element for development. By running `npm run build:watch` and `npm run serve` you can edit and see changes without bundling.
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<!doctype html>
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta charset="utf-8" />
|
||||
<title><my-element> Demo</title>
|
||||
<script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="../node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="../my-element.js"></script>
|
||||
<style>
|
||||
p {
|
||||
|
||||
2
docs-src/.eleventyignore
Normal file
2
docs-src/.eleventyignore
Normal file
@@ -0,0 +1,2 @@
|
||||
# Ignore files with a leading underscore; useful for e.g. readmes in source documentation
|
||||
_*.md
|
||||
@@ -1,7 +1,15 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = () => {
|
||||
const customElements = JSON.parse(fs.readFileSync('custom-elements.json', 'utf-8'));
|
||||
const customElements = JSON.parse(
|
||||
fs.readFileSync('custom-elements.json', 'utf-8')
|
||||
);
|
||||
return {
|
||||
customElements,
|
||||
};
|
||||
|
||||
@@ -4,8 +4,7 @@ const relative = require('./relative-path.cjs');
|
||||
/**
|
||||
* This template extends the page template and adds an examples list.
|
||||
*/
|
||||
module.exports = function(data) {
|
||||
|
||||
module.exports = function (data) {
|
||||
return page({
|
||||
...data,
|
||||
content: renderExample(data),
|
||||
@@ -18,13 +17,22 @@ const renderExample = ({name, content, collections, page}) => {
|
||||
<section class="examples">
|
||||
<nav class="collection">
|
||||
<ul>
|
||||
${collections.example === undefined
|
||||
${
|
||||
collections.example === undefined
|
||||
? ''
|
||||
: collections.example.map((post) => `
|
||||
: collections.example
|
||||
.map(
|
||||
(post) => `
|
||||
<li class=${post.url === page.url ? 'selected' : ''}>
|
||||
<a href="${relative(page.url, post.url)}">${post.data.description.replace('<', '<')}</a>
|
||||
<a href="${relative(
|
||||
page.url,
|
||||
post.url
|
||||
)}">${post.data.description.replace('<', '<')}</a>
|
||||
</li>
|
||||
`).join('')}
|
||||
`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
<div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
module.exports = function(data) {
|
||||
module.exports = function (data) {
|
||||
return `
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/PolymerLabs/lit-element-starter-ts">lit-element-starter-ts</a>
|
||||
<a href="https://github.com/PolymerLabs/lit-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>`;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = function(data) {
|
||||
module.exports = function (data) {
|
||||
return `
|
||||
<header>
|
||||
<h1><my-element></h1>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const relative = require('./relative-path.cjs');
|
||||
|
||||
module.exports = function({page}) {
|
||||
module.exports = function ({page}) {
|
||||
return `
|
||||
<nav>
|
||||
<a href="${relative(page.url, '/')}">Home</a>
|
||||
|
||||
@@ -3,7 +3,7 @@ const footer = require('./footer.11ty.cjs');
|
||||
const nav = require('./nav.11ty.cjs');
|
||||
const relative = require('./relative-path.cjs');
|
||||
|
||||
module.exports = function(data) {
|
||||
module.exports = function (data) {
|
||||
const {title, page, content} = data;
|
||||
return `
|
||||
<!doctype html>
|
||||
@@ -16,7 +16,12 @@ module.exports = function(data) {
|
||||
<link rel="stylesheet" href="${relative(page.url, '/docs.css')}">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="${relative(page.url, '/prism-okaidia.css')}" rel="stylesheet" />
|
||||
<script type="module" src="${relative(page.url, '/my-element.bundled.js')}"></script>
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="${relative(
|
||||
page.url,
|
||||
'/my-element.bundled.js'
|
||||
)}"></script>
|
||||
</head>
|
||||
<body>
|
||||
${header()}
|
||||
|
||||
@@ -15,7 +15,9 @@ module.exports = class Docs {
|
||||
const tags = customElements.tags;
|
||||
return `
|
||||
<h1>API</h1>
|
||||
${tags.map((tag) => `
|
||||
${tags
|
||||
.map(
|
||||
(tag) => `
|
||||
<h2><${tag.name}></h2>
|
||||
<div>
|
||||
${tag.description}
|
||||
@@ -23,41 +25,40 @@ module.exports = class Docs {
|
||||
${renderTable(
|
||||
'Attributes',
|
||||
['name', 'description', 'type', 'default'],
|
||||
tag.attributes)}
|
||||
tag.attributes
|
||||
)}
|
||||
${renderTable(
|
||||
'Properties',
|
||||
['name', 'attribute', 'description', 'type', 'default'],
|
||||
tag.properties)}
|
||||
${/*
|
||||
tag.properties
|
||||
)}
|
||||
${
|
||||
/*
|
||||
* Methods are not output by web-component-analyzer yet (a bug), so
|
||||
* this is a placeholder so that at least _something_ will be output
|
||||
* when that is fixed, and element maintainers will hopefully have a
|
||||
* signal to update this file to add the neccessary columns.
|
||||
*/
|
||||
renderTable(
|
||||
'Methods',
|
||||
['name', 'description'],
|
||||
tag.methods)}
|
||||
${renderTable(
|
||||
'Events',
|
||||
['name', 'description'],
|
||||
tag.events)}
|
||||
${renderTable(
|
||||
'Slots',
|
||||
['name', 'description'],
|
||||
tag.slots)}
|
||||
renderTable('Methods', ['name', 'description'], tag.methods)
|
||||
}
|
||||
${renderTable('Events', ['name', 'description'], tag.events)}
|
||||
${renderTable('Slots', ['name', 'description'], tag.slots)}
|
||||
${renderTable(
|
||||
'CSS Shadow Parts',
|
||||
['name', 'description'],
|
||||
tag.cssParts)}
|
||||
tag.cssParts
|
||||
)}
|
||||
${renderTable(
|
||||
'CSS Custom Properties',
|
||||
['name', 'description'],
|
||||
tag.cssProperties)}
|
||||
`).join('')}
|
||||
tag.cssProperties
|
||||
)}
|
||||
`
|
||||
)
|
||||
.join('')}
|
||||
`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders a table of data, plucking the given properties from each item in
|
||||
@@ -65,7 +66,7 @@ module.exports = class Docs {
|
||||
*/
|
||||
const renderTable = (name, properties, data) => {
|
||||
if (data === undefined) {
|
||||
return ''
|
||||
return '';
|
||||
}
|
||||
return `
|
||||
<h3>${name}</h3>
|
||||
@@ -73,13 +74,17 @@ const renderTable = (name, properties, data) => {
|
||||
<tr>
|
||||
${properties.map((p) => `<th>${capitalize(p)}</th>`).join('')}
|
||||
</tr>
|
||||
${data.map((i) => `
|
||||
${data
|
||||
.map(
|
||||
(i) => `
|
||||
<tr>
|
||||
${properties.map((p) => `<td>${i[p]}</td>`).join('')}
|
||||
</tr>
|
||||
`).join('')}
|
||||
`
|
||||
)
|
||||
.join('')}
|
||||
</table>
|
||||
`
|
||||
`;
|
||||
};
|
||||
|
||||
const capitalize = (s) => s[0].toUpperCase() + s.substring(1);
|
||||
|
||||
@@ -19,10 +19,10 @@ description: A basic example
|
||||
<h3>CSS</h3>
|
||||
|
||||
```css
|
||||
p {
|
||||
border: solid 1px blue;
|
||||
padding: 8px;
|
||||
}
|
||||
p {
|
||||
border: solid 1px blue;
|
||||
padding: 8px;
|
||||
}
|
||||
```
|
||||
|
||||
<h3>HTML</h3>
|
||||
|
||||
@@ -55,12 +55,15 @@ title: <my-element> ⌲ Home
|
||||
```js
|
||||
import {html, render} from 'lit-html';
|
||||
|
||||
const name="lit-html";
|
||||
const name = 'lit-html';
|
||||
|
||||
render(html`
|
||||
<h2>This is a <my-element></h2>
|
||||
<my-element .name=${name}></my-element>
|
||||
`, document.body);
|
||||
render(
|
||||
html`
|
||||
<h2>This is a <my-element></h2>
|
||||
<my-element .name=${name}></my-element>
|
||||
`,
|
||||
document.body
|
||||
);
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
@@ -20,11 +20,13 @@ npm CDNs like [unpkg.com]() can directly serve files that have been published to
|
||||
For this element to work from unpkg.com specifically, you need to include the `?module` query parameter, which tells unpkg.com to rewrite "bare" module specificers to full URLs.
|
||||
|
||||
### HTML
|
||||
|
||||
```html
|
||||
<script type="module" src="https://unpkg.com/my-element?module"></script>
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
|
||||
```html
|
||||
import {MyElement} from 'https://unpkg.com/my-element?module';
|
||||
```
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<p>This directory containts the sources for the static site contained in the /docs/ directory. The site is based on the <a href="11ty.dev">eleventy</a> static site generator.</p>
|
||||
<p>The site is intended to be used with GitHub pages. To enable the site go to the GitHub settings and change the GitHub Pages "Source" setting to "master branch /docs folder".</p>
|
||||
<p>To view the site locally, run <code>npm run docs:serve</code>.</p>
|
||||
<p>To edit the site, add to or edit the files in this directory then run <code>npm run docs</code> to build the site. The built files must be checked in and pushed to GitHub to appear on GitHub pages.</p>
|
||||
@@ -9,6 +9,8 @@
|
||||
<link rel="stylesheet" href="../docs.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="../prism-okaidia.css" rel="stylesheet" />
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="../my-element.bundled.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -65,6 +67,32 @@
|
||||
<td>count</td><td>count</td><td>The number of times the button has been clicked.</td><td>number</td><td>0</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>renderRoot</td><td>undefined</td><td>Node or ShadowRoot into which element DOM should be rendered. Defaults
|
||||
to an open shadowRoot.</td><td>HTMLElement | ShadowRoot</td><td>undefined</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>isUpdatePending</td><td>undefined</td><td>undefined</td><td>boolean</td><td>undefined</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>hasUpdated</td><td>undefined</td><td>undefined</td><td>boolean</td><td>undefined</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>updateComplete</td><td>undefined</td><td>Returns a Promise that resolves when the element has completed updating.
|
||||
The Promise value is a boolean that is `true` if the element completed the
|
||||
update without triggering another update. The Promise result is `false` if
|
||||
a property was set inside `updated()`. If the Promise is rejected, an
|
||||
exception was thrown during the update.
|
||||
|
||||
To await additional asynchronous work, override the `getUpdateComplete`
|
||||
method. For example, it is sometimes useful to await a rendered element
|
||||
before fulfilling this Promise. To do this, first await
|
||||
`super.getUpdateComplete()`, then any subsequent state.</td><td>Promise<boolean></td><td>undefined</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
@@ -104,7 +132,7 @@
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/PolymerLabs/lit-element-starter-ts">lit-element-starter-ts</a>
|
||||
<a href="https://github.com/PolymerLabs/lit-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
<link rel="stylesheet" href="../docs.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="../prism-okaidia.css" rel="stylesheet" />
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="../my-element.bundled.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -32,14 +34,14 @@
|
||||
<nav class="collection">
|
||||
<ul>
|
||||
|
||||
<li class=selected>
|
||||
<a href="">A basic example</a>
|
||||
</li>
|
||||
|
||||
<li class=>
|
||||
<a href="name-property/">Setting the name property</a>
|
||||
</li>
|
||||
|
||||
<li class=selected>
|
||||
<a href="">A basic example</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
<div>
|
||||
@@ -53,7 +55,7 @@
|
||||
<p>This is child content</p>
|
||||
</my-element>
|
||||
<h3>CSS</h3>
|
||||
<pre class="language-css"><code class="language-css"> <span class="token selector">p</span> <span class="token punctuation">{</span><br> <span class="token property">border</span><span class="token punctuation">:</span> solid 1px blue<span class="token punctuation">;</span><br> <span class="token property">padding</span><span class="token punctuation">:</span> 8px<span class="token punctuation">;</span><br> <span class="token punctuation">}</span></code></pre>
|
||||
<pre class="language-css"><code class="language-css"><span class="token selector">p</span> <span class="token punctuation">{</span><br> <span class="token property">border</span><span class="token punctuation">:</span> solid 1px blue<span class="token punctuation">;</span><br> <span class="token property">padding</span><span class="token punctuation">:</span> 8px<span class="token punctuation">;</span><br><span class="token punctuation">}</span></code></pre>
|
||||
<h3>HTML</h3>
|
||||
<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>my-element</span><span class="token punctuation">></span></span><br> <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>This is child content<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span><br><span class="token tag"><span class="token tag"><span class="token punctuation"></</span>my-element</span><span class="token punctuation">></span></span></code></pre>
|
||||
|
||||
@@ -66,7 +68,7 @@
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/PolymerLabs/lit-element-starter-ts">lit-element-starter-ts</a>
|
||||
<a href="https://github.com/PolymerLabs/lit-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
<link rel="stylesheet" href="../../docs.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="../../prism-okaidia.css" rel="stylesheet" />
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="../../my-element.bundled.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -32,20 +34,20 @@
|
||||
<nav class="collection">
|
||||
<ul>
|
||||
|
||||
<li class=>
|
||||
<a href="../">A basic example</a>
|
||||
</li>
|
||||
|
||||
<li class=selected>
|
||||
<a href="">Setting the name property</a>
|
||||
</li>
|
||||
|
||||
<li class=>
|
||||
<a href="../">A basic example</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
<div>
|
||||
<p><my-element name="Earth"></my-element></p>
|
||||
<h3>HTML</h3>
|
||||
<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</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"></</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"><</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"></</span>my-element</span><span class="token punctuation">></span></span></code></pre>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
@@ -56,7 +58,7 @@
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/PolymerLabs/lit-element-starter-ts">lit-element-starter-ts</a>
|
||||
<a href="https://github.com/PolymerLabs/lit-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
<link rel="stylesheet" href="docs.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="prism-okaidia.css" rel="stylesheet" />
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="my-element.bundled.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -42,7 +44,7 @@
|
||||
<section class="columns">
|
||||
<div>
|
||||
<p><code><my-element></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"><</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"></</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"><</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"></</span>my-element</span><span class="token punctuation">></span></span></code></pre>
|
||||
</div>
|
||||
<div>
|
||||
<p><my-element name="HTML"></my-element></p>
|
||||
@@ -52,7 +54,7 @@
|
||||
<section class="columns">
|
||||
<div>
|
||||
<p><code><my-element></code> can be used with declarative rendering libraries like Angular, React, Vue, and lit-html</p>
|
||||
<pre class="language-js"><code class="language-js"><span class="token keyword">import</span> <span class="token punctuation">{</span>html<span class="token punctuation">,</span> render<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'lit-html'</span><span class="token punctuation">;</span><br><br><span class="token keyword">const</span> name<span class="token operator">=</span><span class="token string">"lit-html"</span><span class="token punctuation">;</span><br><br><span class="token function">render</span><span class="token punctuation">(</span>html<span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string"><br> <h2>This is a &lt;my-element&gt;</h2><br> <my-element .name=</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>name<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">></my-element><br></span><span class="token template-punctuation string">`</span></span><span class="token punctuation">,</span> document<span class="token punctuation">.</span>body<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
|
||||
<pre class="language-js"><code class="language-js"><span class="token keyword">import</span> <span class="token punctuation">{</span>html<span class="token punctuation">,</span> render<span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'lit-html'</span><span class="token punctuation">;</span><br><br><span class="token keyword">const</span> name <span class="token operator">=</span> <span class="token string">'lit-html'</span><span class="token punctuation">;</span><br><br><span class="token function">render</span><span class="token punctuation">(</span><br> html<span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string"><br> <h2>This is a &lt;my-element&gt;</h2><br> <my-element .name=</span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>name<span class="token interpolation-punctuation punctuation">}</span></span><span class="token string">></my-element><br> </span><span class="token template-punctuation string">`</span></span><span class="token punctuation">,</span><br> document<span class="token punctuation">.</span>body<br><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
|
||||
</div>
|
||||
<div>
|
||||
<h2>This is a <my-element></h2>
|
||||
@@ -66,7 +68,7 @@
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/PolymerLabs/lit-element-starter-ts">lit-element-starter-ts</a>
|
||||
<a href="https://github.com/PolymerLabs/lit-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
<link rel="stylesheet" href="../docs.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">
|
||||
<link href="../prism-okaidia.css" rel="stylesheet" />
|
||||
<script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
|
||||
<script src="/node_modules/lit/polyfill-support.js"></script>
|
||||
<script type="module" src="../my-element.bundled.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@@ -34,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>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 "bare" module specificers to full URLs.</p>
|
||||
<h3>HTML</h3>
|
||||
<pre class="language-html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</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"></</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"><</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"></</span>script</span><span class="token punctuation">></span></span></code></pre>
|
||||
<h3>JavaScript</h3>
|
||||
<pre class="language-html"><code class="language-html">import {MyElement} from 'https://unpkg.com/my-element?module';</code></pre>
|
||||
|
||||
@@ -44,7 +46,7 @@
|
||||
<footer>
|
||||
<p>
|
||||
Made with
|
||||
<a href="https://github.com/PolymerLabs/lit-element-starter-ts">lit-element-starter-ts</a>
|
||||
<a href="https://github.com/PolymerLabs/lit-starter-ts">lit-starter-ts</a>
|
||||
</p>
|
||||
</footer>
|
||||
</body>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -52,7 +52,7 @@ pre[class*="language-"] {
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
color: #8292a2;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
const {createDefaultConfig} = require('@open-wc/testing-karma');
|
||||
const merge = require('deepmerge');
|
||||
|
||||
module.exports = (config) => {
|
||||
config.set(
|
||||
merge(createDefaultConfig(config), {
|
||||
frameworks: ['mocha', 'chai'],
|
||||
client: {
|
||||
mocha: {ui: 'tdd'},
|
||||
},
|
||||
files: [
|
||||
{
|
||||
pattern: config.grep ? config.grep : 'test/**/*_test.js',
|
||||
type: 'module',
|
||||
},
|
||||
],
|
||||
// See the karma-esm docs for all options
|
||||
esm: {
|
||||
nodeResolve: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
return config;
|
||||
};
|
||||
26373
package-lock.json
generated
26373
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
52
package.json
52
package.json
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "lit-element-starter-ts",
|
||||
"name": "@lit/lit-starter-ts",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"description": "A simple web component",
|
||||
"main": "my-element.js",
|
||||
@@ -12,57 +13,58 @@
|
||||
"lint": "npm run lint:lit-analyzer && npm run lint:eslint",
|
||||
"lint:eslint": "eslint 'src/**/*.ts'",
|
||||
"lint:lit-analyzer": "lit-analyzer",
|
||||
"format": "prettier src/* --write",
|
||||
"format": "prettier \"**/*.{cjs,html,js,json,md,ts}\" --ignore-path ./.eslintignore --write",
|
||||
"docs": "npm run docs:clean && npm run build && npm run analyze && npm run docs:build && npm run docs:assets && npm run docs:gen",
|
||||
"docs:clean": "rimraf docs",
|
||||
"docs:gen": "eleventy --config=.eleventy.cjs",
|
||||
"docs:gen:watch": "eleventy --config=.eleventy.cjs --watch",
|
||||
"docs:build": "rollup -c --file docs/my-element.bundled.js",
|
||||
"docs:assets": "cp node_modules/prismjs/themes/prism-okaidia.css docs/",
|
||||
"docs:serve": "es-dev-server --root-dir=docs --node-resolve --watch",
|
||||
"docs:serve": "wds --root-dir=docs --node-resolve --watch",
|
||||
"analyze": "wca analyze \"src/**/*.ts\" --outFile custom-elements.json",
|
||||
"serve": "es-dev-server --node-resolve --watch",
|
||||
"test": "karma start karma.conf.cjs",
|
||||
"test:watch": "karma start karma.conf.cjs --auto-watch=true --single-run=false",
|
||||
"test:update-snapshots": "karma start karma.conf.cjs --update-snapshots",
|
||||
"test:prune-snapshots": "karma start karma.conf.cjs --prune-snapshots",
|
||||
"serve": "wds --watch",
|
||||
"test": "wtr",
|
||||
"test:watch": "npm run test -- --watch",
|
||||
"checksize": "rollup -c ; cat my-element.bundled.js | gzip -9 | wc -c ; rm my-element.bundled.js"
|
||||
},
|
||||
"keywords": [
|
||||
"web-components",
|
||||
"lit-element",
|
||||
"typescript"
|
||||
"typescript",
|
||||
"lit"
|
||||
],
|
||||
"author": "The Polymer Authors",
|
||||
"author": "Google LLC",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"lit-element": "^2.3.1"
|
||||
"lit": "^2.0.0-rc.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@11ty/eleventy": "^0.10.0",
|
||||
"@11ty/eleventy": "^0.12.1",
|
||||
"@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1",
|
||||
"@open-wc/testing": "^2.5.10",
|
||||
"@open-wc/testing-karma": "^3.3.11",
|
||||
"@rollup/plugin-replace": "^2.3.1",
|
||||
"@types/chai": "^4.2.11",
|
||||
"@esm-bundle/chai": "^4.1.5",
|
||||
"@open-wc/testing": "^2.5.32",
|
||||
"@open-wc/testing-karma": "^4.0.9",
|
||||
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||
"@rollup/plugin-replace": "^2.3.3",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@typescript-eslint/eslint-plugin": "^2.27.0",
|
||||
"@typescript-eslint/parser": "^2.27.0",
|
||||
"chai": "^4.2.0",
|
||||
"@web/dev-server": "0.0.29",
|
||||
"@web/dev-server-legacy": "^0.1.4",
|
||||
"@web/dev-server-rollup": "^0.2.7",
|
||||
"@web/test-runner": "^0.12.15",
|
||||
"@web/test-runner-mocha": "^0.3.5",
|
||||
"@web/test-runner-playwright": "^0.8.4",
|
||||
"@webcomponents/webcomponentsjs": "^2.5.0",
|
||||
"deepmerge": "^4.2.2",
|
||||
"es-dev-server": "^1.46.1",
|
||||
"eslint": "^6.8.0",
|
||||
"karma": "^4.4.1",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"lit-analyzer": "^1.1.10",
|
||||
"mocha": "^7.1.1",
|
||||
"prettier": "^2.0.4",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^1.32.1",
|
||||
"rollup-plugin-filesize": "^7.0.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-terser": "^5.3.0",
|
||||
"rollup": "^2.28.2",
|
||||
"rollup-plugin-summary": "^1.2.3",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"typescript": "^3.8.3",
|
||||
"web-component-analyzer": "^1.0.3"
|
||||
}
|
||||
|
||||
@@ -1,20 +1,12 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at
|
||||
* 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
|
||||
* Copyright 2018 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
import filesize from 'rollup-plugin-filesize';
|
||||
import summary from 'rollup-plugin-summary';
|
||||
import {terser} from 'rollup-plugin-terser';
|
||||
import resolve from 'rollup-plugin-node-resolve';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import replace from '@rollup/plugin-replace';
|
||||
|
||||
export default {
|
||||
@@ -32,6 +24,7 @@ export default {
|
||||
replace({'Reflect.decorate': 'undefined'}),
|
||||
resolve(),
|
||||
terser({
|
||||
ecma: 2017,
|
||||
module: true,
|
||||
warnings: true,
|
||||
mangle: {
|
||||
@@ -40,8 +33,6 @@ export default {
|
||||
},
|
||||
},
|
||||
}),
|
||||
filesize({
|
||||
showBrotliSize: true,
|
||||
}),
|
||||
summary(),
|
||||
],
|
||||
};
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
|
||||
* This code may only be used under the BSD style license found at
|
||||
* 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
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
import {LitElement, html, customElement, property, css} from 'lit-element';
|
||||
import {LitElement, html, css} from 'lit';
|
||||
import {customElement, property} from 'lit/decorators.js';
|
||||
|
||||
/**
|
||||
* An example element.
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
import {MyElement} from '../my-element.js';
|
||||
|
||||
import {fixture, html} from '@open-wc/testing';
|
||||
|
||||
const assert = chai.assert;
|
||||
@@ -47,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');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2017",
|
||||
"module": "es2015",
|
||||
"lib": ["es2017", "dom", "dom.iterable"],
|
||||
"target": "es2019",
|
||||
"module": "es2020",
|
||||
"lib": ["es2020", "DOM", "DOM.Iterable"],
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"outDir": "./",
|
||||
"rootDir": "./src",
|
||||
"strict": true,
|
||||
@@ -13,6 +14,8 @@
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
|
||||
20
web-dev-server.config.js
Normal file
20
web-dev-server.config.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2021 Google LLC
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
import {legacyPlugin} from '@web/dev-server-legacy';
|
||||
|
||||
export default {
|
||||
nodeResolve: true,
|
||||
preserveSymlinks: true,
|
||||
plugins: [
|
||||
legacyPlugin({
|
||||
polyfills: {
|
||||
// Manually imported in index.html file
|
||||
webcomponents: false,
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
119
web-test-runner.config.js
Normal file
119
web-test-runner.config.js
Normal file
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* @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;
|
||||
try {
|
||||
commandLineBrowsers = process.env.BROWSERS?.split(',').map(
|
||||
(b) => browsers[b] ?? noBrowser(b)
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
|
||||
// https://modern-web.dev/docs/test-runner/cli-and-configuration/
|
||||
export default {
|
||||
rootDir: '.',
|
||||
files: ['./test/**/*_test.js'],
|
||||
nodeResolve: true,
|
||||
preserveSymlinks: true,
|
||||
browsers: commandLineBrowsers ?? Object.values(browsers),
|
||||
testFramework: {
|
||||
// https://mochajs.org/api/mocha
|
||||
config: {
|
||||
ui: 'tdd',
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
// Detect browsers without modules (e.g. IE11) and transform to SystemJS
|
||||
// (https://modern-web.dev/docs/dev-server/plugins/legacy/).
|
||||
legacyPlugin({
|
||||
polyfills: {
|
||||
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,
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user