diff --git a/.prettierignore b/.prettierignore
index 41c915fed..e37db73b2 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -8,8 +8,5 @@ package-lock.json
/packages/lit-dev-content/_dev/
/packages/lit-dev-content/_site/
/packages/lit-dev-content/rollupout/
-# TODO(aomarks) Would be nice to format samples, but Prettier doesn't always do
-# a great job compared to our manual formatting.
-/packages/lit-dev-content/samples/
.wireit
diff --git a/lit-dev.code-workspace b/lit-dev.code-workspace
index 70a44ab67..9b3af68c6 100644
--- a/lit-dev.code-workspace
+++ b/lit-dev.code-workspace
@@ -2,48 +2,48 @@
"folders": [
{
"name": "lit-dev-content",
- "path": "packages/lit-dev-content"
+ "path": "packages/lit-dev-content",
},
{
"name": "lit-dev-tools-cjs",
- "path": "packages/lit-dev-tools-cjs"
+ "path": "packages/lit-dev-tools-cjs",
},
{
"name": "lit-dev-tools-esm",
- "path": "packages/lit-dev-tools-esm"
+ "path": "packages/lit-dev-tools-esm",
},
{
"name": "lit-dev-tests",
- "path": "packages/lit-dev-tests"
+ "path": "packages/lit-dev-tests",
},
{
"name": "lit-dev-api",
- "path": "packages/lit-dev-api"
+ "path": "packages/lit-dev-api",
},
{
"name": "lit-dev-server",
- "path": "packages/lit-dev-server"
+ "path": "packages/lit-dev-server",
},
{
"name": "lit-dev-discord-bot",
- "path": "packages/lit-dev-discord-bot"
+ "path": "packages/lit-dev-discord-bot",
},
{
"name": "lit.dev",
- "path": "."
- }
+ "path": ".",
+ },
],
"settings": {
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"[typescript]": {
- "editor.defaultFormatter": "esbenp.prettier-vscode"
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
},
"search.exclude": {
- "api-data/*/repo": true
+ "api-data/*/repo": true,
},
},
"extensions": {
- "recommendations": ["esbenp.prettier-vscode"]
- }
+ "recommendations": ["esbenp.prettier-vscode"],
+ },
}
diff --git a/package-lock.json b/package-lock.json
index 8652c0cd7..4d271beba 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -13,7 +13,7 @@
],
"devDependencies": {
"playground-elements": "^0.20.0",
- "prettier": "^2.1.2",
+ "prettier": "^3.5.3",
"typescript": "~4.7.4",
"wireit": "^0.14.0"
}
@@ -6963,13 +6963,15 @@
}
},
"node_modules/prettier": {
- "version": "2.7.1",
+ "version": "3.5.3",
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz",
+ "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==",
"license": "MIT",
"bin": {
- "prettier": "bin-prettier.js"
+ "prettier": "bin/prettier.cjs"
},
"engines": {
- "node": ">=10.13.0"
+ "node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
@@ -8982,7 +8984,7 @@
"fast-glob": "^3.2.9",
"lit-dev-server": "^0.0.0",
"lit-dev-tools-cjs": "^0.0.0",
- "prettier": "^2.3.2"
+ "prettier": "^3.5.3"
}
}
}
diff --git a/package.json b/package.json
index d3d67555b..86a55232b 100644
--- a/package.json
+++ b/package.json
@@ -62,7 +62,7 @@
},
"devDependencies": {
"playground-elements": "^0.20.0",
- "prettier": "^2.1.2",
+ "prettier": "^3.5.3",
"typescript": "~4.7.4",
"wireit": "^0.14.0"
}
diff --git a/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts b/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
index c4bcbe5cc..ca7b5249a 100644
--- a/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
+++ b/packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
@@ -39,7 +39,7 @@ async function main() {
if (!PROJECT_ID || !REPO_NAME || !_DEPLOY_REGION) {
console.log({PROJECT_ID, REPO_NAME, _DEPLOY_REGION});
throw new Error(
- 'Missing one or more required environment variables: PROJECT_ID, REPO_NAME, _DEPLOY_REGION'
+ 'Missing one or more required environment variables: PROJECT_ID, REPO_NAME, _DEPLOY_REGION',
);
}
@@ -98,7 +98,7 @@ async function main() {
!rev.metadata.name
) {
throw new Error(
- `Found revision with missing necessary metadata: ${JSON.stringify(rev)}`
+ `Found revision with missing necessary metadata: ${JSON.stringify(rev)}`,
);
}
@@ -160,7 +160,7 @@ async function main() {
} else if (!t.tag.startsWith('main')) {
// Unrecognized tags are kept just in case
console.log(
- `Found unrecognized tag "${t.tag}". This will not be deleted.`
+ `Found unrecognized tag "${t.tag}". This will not be deleted.`,
);
revisionsToKeep.add(t.revisionName);
return true;
diff --git a/packages/lit-dev-content/.eleventy.js b/packages/lit-dev-content/.eleventy.js
index 3e575cec1..eef15d50a 100644
--- a/packages/lit-dev-content/.eleventy.js
+++ b/packages/lit-dev-content/.eleventy.js
@@ -71,7 +71,7 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addWatchTarget('../lit-dev-api/api-data/*/*.json');
eleventyConfig.addWatchTarget(
- '../lit-dev-content/samples/tutorials/**/tutorial.json'
+ '../lit-dev-content/samples/tutorials/**/tutorial.json',
);
eleventyConfig.addWatchTarget('../lit-dev-content/samples/tutorials/**/*.md');
eleventyConfig.addWatchTarget('../lit-dev-content/rollupout/server/*');
@@ -119,14 +119,14 @@ ${content}
Object.assign(new state.Token('div_open', 'div', 1), {
attrs: [['class', `heading ${headingTag}`]],
block: true,
- })
+ }),
);
state.tokens.splice(
idx + 4,
0,
Object.assign(new state.Token('div_close', 'div', -1), {
block: true,
- })
+ }),
);
linkAfterHeaderBase(slug, opts, state, idx + 1);
};
@@ -165,16 +165,16 @@ ${content}
function (url, latestVersion) {
if (!latestVersion) {
throw new Error(
- `No latestVersion provided to 'removeLatestVersionFromUrl`
+ `No latestVersion provided to 'removeLatestVersionFromUrl`,
);
}
if (!url.includes(`/${latestVersion}/`)) {
throw new Error(
- `'${url}' does not include the latestVersion versioned path segment`
+ `'${url}' does not include the latestVersion versioned path segment`,
);
}
return url.replace(`/${latestVersion}/`, '/');
- }
+ },
);
/**
@@ -191,11 +191,11 @@ ${content}
}
if (!latestVersion) {
throw new Error(
- `latestVersion not provided to 'fixUnversionedCrossLinks`
+ `latestVersion not provided to 'fixUnversionedCrossLinks`,
);
}
return content.replaceAll(`/docs/${latestVersion}/`, '/docs/');
- }
+ },
);
eleventyConfig.addFilter('removeExtension', function (url) {
@@ -446,7 +446,7 @@ ${content}
if (location === undefined) {
throw new Error(
`Ambiguous symbol ${symbol}. ` +
- `Options: ${locations.map((l) => l.anchor).join(', ')}`
+ `Options: ${locations.map((l) => l.anchor).join(', ')}`,
);
}
@@ -459,8 +459,8 @@ ${content}
'api-v3',
'/docs/v3/api',
JSON.parse(
- fsSync.readFileSync('../lit-dev-api/api-data/lit-3/symbols.json', 'utf8')
- )
+ fsSync.readFileSync('../lit-dev-api/api-data/lit-3/symbols.json', 'utf8'),
+ ),
);
addApiShortcode(
@@ -468,8 +468,8 @@ ${content}
'/docs/v2/api',
// Don't use require() because of Node caching in watch mode.
JSON.parse(
- fsSync.readFileSync('../lit-dev-api/api-data/lit-2/symbols.json', 'utf8')
- )
+ fsSync.readFileSync('../lit-dev-api/api-data/lit-2/symbols.json', 'utf8'),
+ ),
);
addApiShortcode(
@@ -478,9 +478,9 @@ ${content}
JSON.parse(
fsSync.readFileSync(
'../lit-dev-api/api-data/lit-html-1/symbols.json',
- 'utf8'
- )
- )
+ 'utf8',
+ ),
+ ),
);
addApiShortcode(
@@ -489,9 +489,9 @@ ${content}
JSON.parse(
fsSync.readFileSync(
'../lit-dev-api/api-data/lit-element-2/symbols.json',
- 'utf8'
- )
- )
+ 'utf8',
+ ),
+ ),
);
/**
@@ -520,7 +520,7 @@ ${content}
`CleanCSS errors/warnings on file ${path}:\n\n${[
...result.errors,
...result.warnings,
- ].join('\n')}`
+ ].join('\n')}`,
);
}
return ``;
@@ -554,14 +554,14 @@ ${content}
// Source: https://github.com/11ty/eleventy-base-blog/blob/master/.eleventy.js
eleventyConfig.addFilter('readableDate', (dateObj) => {
return luxon.DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat(
- 'LLL d, yyyy'
+ 'LLL d, yyyy',
);
});
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
eleventyConfig.addFilter('yyyymmdd', (dateObj) => {
return luxon.DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat(
- 'yyyy-LL-dd'
+ 'yyyy-LL-dd',
);
});
@@ -587,7 +587,7 @@ ${content}
ENV.eleventyOutDir + '/docs/v3/introduction.html',
ENV.eleventyOutDir + '/docs/v3/*/index.html',
],
- {ignore: ENV.eleventyOutDir + '/docs/(v1|v2|v3)/index.html'}
+ {ignore: ENV.eleventyOutDir + '/docs/(v1|v2|v3)/index.html'},
)
).filter(
// TODO(aomarks) This is brittle, we need a way to annotate inside an md
@@ -595,7 +595,7 @@ ${content}
(file) =>
!file.includes('why-lit') &&
!file.includes('getting-started') &&
- !file.includes('browser-support')
+ !file.includes('browser-support'),
);
await Promise.all(emptyDocsIndexFiles.map((path) => fs.unlink(path)));
@@ -611,32 +611,32 @@ ${content}
// immediately, instead of triggering an Eleventy build.
await symlinkForce(
path.join(__dirname, 'site', 'css'),
- path.join(__dirname, ENV.eleventyOutDir, 'css')
+ path.join(__dirname, ENV.eleventyOutDir, 'css'),
);
await symlinkForce(
path.join(__dirname, 'site', 'images'),
- path.join(__dirname, ENV.eleventyOutDir, 'images')
+ path.join(__dirname, ENV.eleventyOutDir, 'images'),
);
await symlinkForce(
path.join(__dirname, 'site', 'fonts'),
- path.join(__dirname, ENV.eleventyOutDir, 'fonts')
+ path.join(__dirname, ENV.eleventyOutDir, 'fonts'),
);
await symlinkForce(
path.join(__dirname, 'samples'),
- path.join(__dirname, ENV.eleventyOutDir, 'samples')
+ path.join(__dirname, ENV.eleventyOutDir, 'samples'),
);
// Symlink lib -> _dev/js. This lets us directly reference tsc outputs in
// dev mode, instead of the Rollup bundles we use for production.
await symlinkForce(
path.join(__dirname, 'lib'),
- path.join(__dirname, ENV.eleventyOutDir, 'js')
+ path.join(__dirname, ENV.eleventyOutDir, 'js'),
);
} else {
// Inline all Playground project files directly into their manifests, to
// cut down on requests per project.
await inlinePlaygroundFilesIntoManifests(
- `${ENV.eleventyOutDir}/samples/**/project.json`
+ `${ENV.eleventyOutDir}/samples/**/project.json`,
);
// Pre-compress all outputs as .br and .gz files so the server can read
@@ -649,7 +649,7 @@ ${content}
await fs.writeFile(
path.join(ENV.eleventyOutDir, 'csp-inline-script-hashes.txt'),
[...cspInlineScriptHashes].join('\n'),
- 'utf8'
+ 'utf8',
);
}
});
@@ -676,7 +676,7 @@ ${content}
// In prod SSR should use the lit templates run through the minifier.
if (!DEV) {
componentModules = componentModules.map((componentPath) =>
- componentPath.replace('lib/components', 'rollupout/server')
+ componentPath.replace('lib/components', 'rollupout/server'),
);
}
diff --git a/packages/lit-dev-content/samples/_check-code-helpers.ts b/packages/lit-dev-content/samples/_check-code-helpers.ts
index e819a6a96..002cffc6b 100644
--- a/packages/lit-dev-content/samples/_check-code-helpers.ts
+++ b/packages/lit-dev-content/samples/_check-code-helpers.ts
@@ -1,6 +1,8 @@
import {PostDoc} from 'postdoc-lib';
-export const installCodeChecker = async (checkCode: () => Promise<{passed: boolean, message?: string}>) => {
+export const installCodeChecker = async (
+ checkCode: () => Promise<{passed: boolean; message?: string}>,
+) => {
const postDoc = new PostDoc({
messageTarget: window.top!,
messageReceiver: window,
@@ -15,9 +17,9 @@ export const installCodeChecker = async (checkCode: () => Promise<{passed: boole
postDoc.postMessage({status, message});
break;
}
- }
+ },
});
await postDoc.handshake;
postDoc.postMessage({status: 'READY'});
-}
\ No newline at end of file
+};
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts
index 9fc3fecd0..36f084a1c 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/add-styles/my-element.ts
@@ -1,10 +1,11 @@
-import { html, LitElement, css } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement, css} from 'lit';
+import {customElement} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
render() {
- return html`
I'm blue
I'm red
`;
+ return html`I'm blue
+ I'm red
`;
}
static styles = css`
@@ -15,4 +16,4 @@ export class MyElement extends LitElement {
color: red;
}
`;
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts
index 9078aee71..c9b34137e 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/input-or-textfield.ts
@@ -1,30 +1,26 @@
-import { html, LitElement } from 'lit';
-import { customElement, property } from 'lit/decorators.js';
-import { html as staticHTML, StaticValue } from 'lit/static-html.js';
+import {html, LitElement} from 'lit';
+import {customElement, property} from 'lit/decorators.js';
+import {html as staticHTML, StaticValue} from 'lit/static-html.js';
@customElement('input-or-textfield')
export class MyElement extends LitElement {
// attribute is false because this is a value that can't be serialized to an
// HTML attribute
- @property({ attribute: false }) tagLiteral: StaticValue|null = null;
+ @property({attribute: false}) tagLiteral: StaticValue | null = null;
@property() value = '';
render() {
return html`
- ${
- staticHTML`
+ ${staticHTML`
<${this.tagLiteral}
@input=${this.#onInput}
.value=${this.value}>${this.tagLiteral}>
- `
- }
-
- The value of the input is: ${this.value}
-
+ `}
+ The value of the input is: ${this.value}
`;
}
#onInput(e: InputEvent) {
- this.value = (e.target as (HTMLInputElement | HTMLTextAreaElement)).value;
+ this.value = (e.target as HTMLInputElement | HTMLTextAreaElement).value;
}
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts
index 8723151f8..86668941e 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/bind-tag-name/my-element.ts
@@ -1,6 +1,6 @@
-import { css, html, LitElement } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
-import { literal } from 'lit/static-html.js';
+import {css, html, LitElement} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
+import {literal} from 'lit/static-html.js';
import './input-or-textfield.js';
@customElement('my-element')
@@ -14,37 +14,49 @@ export class MyElement extends LitElement {
+ type="radio"
+ name="selection"
+ @change=${this.#onChange}
+ value="input"
+ checked
+ />
input
+ type="radio"
+ name="selection"
+ @change=${this.#onChange}
+ value="textarea"
+ />
textarea
+ value="this is the default value"
+ .tagLiteral=${this.tagLiteral}
+ >
`;
}
#onChange(e: InputEvent) {
const target = e.target as HTMLInputElement;
- this.tagLiteral = target.value === 'input' ? literal`input` : literal`textarea`;
+ this.tagLiteral =
+ target.value === 'input' ? literal`input` : literal`textarea`;
}
- static styles = css`/* playground-fold */:host { font-family: sans-serif; } :host > * { margin-block: .5em; }/* playground-fold-end */`;
+ static styles = css`
+ /* playground-fold */
+ :host {
+ font-family: sans-serif;
+ }
+ :host > * {
+ margin-block: 0.5em;
+ } /* playground-fold-end */
+ `;
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts
index e31973473..fea57fa24 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/classes/my-element.ts
@@ -1,19 +1,19 @@
-import { html, LitElement, css } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
-import { classMap } from 'lit/directives/class-map.js';
+import {html, LitElement, css} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
+import {classMap} from 'lit/directives/class-map.js';
@customElement('my-element')
export class MyElement extends LitElement {
- @state() counter = 0
+ @state() counter = 0;
firstUpdated() {
- setInterval(() => this.counter += 1 , 1000);
+ setInterval(() => (this.counter += 1), 1000);
}
render() {
const classes = {
red: this.counter % 2 === 0,
- blue: this.counter % 2 === 1
+ blue: this.counter % 2 === 1,
};
return html`Hello!
`;
}
@@ -26,4 +26,4 @@ export class MyElement extends LitElement {
color: blue;
}
`;
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts
index 860091f41..5a2ab9e87 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/conditionals/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -14,13 +14,18 @@ export class MyElement extends LitElement {
return html`
{this.someBoolean = !this.someBoolean}}>
+ @click=${() => {
+ this.someBoolean = !this.someBoolean;
+ }}
+ >
Toggle template
This is an inline ternary conditional
- ${this.someBoolean ? html`Some other text
` : html`Some text
`}
+ ${this.someBoolean
+ ? html`Some other text
`
+ : html`Some text
`}
This is a variable conditional
${someText}
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts
index 8bd747eee..b003176c3 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/my-element.ts
@@ -1,6 +1,9 @@
-import { html, LitElement } from 'lit';
-import { customElement } from 'lit/decorators.js';
-import { trustedStyles, type CSSStyleSheet } from './trusted-stringified-css-source.js';
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators.js';
+import {
+ trustedStyles,
+ type CSSStyleSheet,
+} from './trusted-stringified-css-source.js';
// Use constructable stylesheets on TRUSTED CSS strings to use them in a LitElement
const styles = new CSSStyleSheet();
@@ -11,10 +14,6 @@ const styles = new CSSStyleSheet();
export class MyElement extends LitElement {
static styles = styles;
render() {
- return html`
-
- This should be red!
-
- `;
+ return html` This should be red!
`;
}
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts
index fce4ea3be..9375f6e47 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/constructable-stylesheets/trusted-stringified-css-source.ts
@@ -5,7 +5,7 @@ export const trustedStyles = `
`;
// This may be needed for some older versions of TS
-export type CSSStyleSheet = typeof globalThis['CSSStyleSheet'] & {
+export type CSSStyleSheet = (typeof globalThis)['CSSStyleSheet'] & {
replaceSync(cssText: string): void;
replace(cssText: string): void;
};
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html
index 63ef6c4b2..18cbd2eb8 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/index.html
@@ -21,4 +21,4 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts
index 6fac25d2d..177b8c074 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/css-shadow-parts/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement, css } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement, css} from 'lit';
+import {customElement} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -15,4 +15,4 @@ export class MyElement extends LitElement {
render() {
return html`This is in a shadow root!
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html
index d0fdb30d1..fb29bb482 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts
index 40810f9c3..2cbe7942d 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/custom-attribute-converter/my-element.ts
@@ -1,5 +1,6 @@
-import { html, LitElement } from 'lit';
-import { customElement, property, state } from 'lit/decorators.js';import {ComplexAttributeConverter} from 'lit';
+import {html, LitElement} from 'lit';
+import {customElement, property, state} from 'lit/decorators.js';
+import {ComplexAttributeConverter} from 'lit';
/**
* Bidirectionally converts an array from an attribute to a property of the
@@ -17,17 +18,15 @@ export const arrayConverter: ComplexAttributeConverter> = {
} catch {
return [];
}
- }
+ },
};
@customElement('my-element')
export class MyElement extends LitElement {
- @property({ converter: arrayConverter, reflect: true })
- array: Array = [];
+ @property({converter: arrayConverter, reflect: true})
+ array: Array = [];
render() {
- return this.array.map((item) =>
- html`${typeof item}: ${item}
`
- );
+ return this.array.map((item) => html`${typeof item}: ${item}
`);
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts
index fdfdab6a8..cf8d0f3e4 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/game-player.ts
@@ -1,5 +1,5 @@
-import { html, LitElement } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators.js';
export type ScoreEvent = CustomEvent;
@@ -13,6 +13,8 @@ export class GamePlayer extends LitElement {
}
handleScore(points: number) {
- this.dispatchEvent(new CustomEvent('score', { detail: points, bubbles: true }));
+ this.dispatchEvent(
+ new CustomEvent('score', {detail: points, bubbles: true}),
+ );
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html
index 0e004d712..bffc611c4 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts
index 6a8d3dd36..07a611d27 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/data-up/score-board.ts
@@ -1,5 +1,5 @@
-import { html, LitElement } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
import './game-player.js';
import type {ScoreEvent} from './game-player.js';
@@ -12,9 +12,13 @@ export class ScoreBoard extends LitElement {
return html`
${this.playerOneScore} - ${this.playerTwoScore}
Player 1
- this.playerOneScore += e.detail}>
+ (this.playerOneScore += e.detail)}
+ >
Player 2
- this.playerTwoScore += e.detail}>
+ (this.playerTwoScore += e.detail)}
+ >
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts
index b4f5ba4d5..51799b93b 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/hello-world.ts
@@ -1,9 +1,9 @@
-import { html, LitElement } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators.js';
@customElement('hello-world')
export class HelloWorld extends LitElement {
render() {
return html`Hello, world!
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html
index c53974764..be6dad253 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/define/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts
index 02705851a..437af20fc 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/derived-state/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html
index e44dfda1c..eac65a81c 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/index.html
@@ -1,5 +1,5 @@
-
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts
index 26ba98f12..96634823c 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-qae/my-pretty-input.ts
@@ -1,5 +1,10 @@
-import { html, LitElement, css } from 'lit';
-import { customElement, property, queryAssignedElements, state } from 'lit/decorators.js';
+import {html, LitElement, css} from 'lit';
+import {
+ customElement,
+ property,
+ queryAssignedElements,
+ state,
+} from 'lit/decorators.js';
@customElement('my-pretty-input')
export class MyPrettyInput extends LitElement {
@@ -43,24 +48,28 @@ export class MyPrettyInput extends LitElement {
// get the array of assigned elements and pick the first one
const input = this.inputs[0];
- input?.animate?.([
- { 'transform': 'scale(1)', easing: 'ease-out' },
- { 'transform': 'scale(2)', easing: 'ease-in' },
- { 'transform': 'scale(1)' }
- ],
- 1000);
+ input?.animate?.(
+ [
+ {transform: 'scale(1)', easing: 'ease-out'},
+ {transform: 'scale(2)', easing: 'ease-in'},
+ {transform: 'scale(1)'},
+ ],
+ 1000,
+ );
};
#onInputBlur = () => {
this.inputFocused = false;
const input = this.inputs[0];
- input?.animate?.([
- { 'transform': 'scale(1)', easing: 'ease-out' },
- { 'transform': 'scale(.75)', easing: 'ease-in' },
- { 'transform': 'scale(1)' }
- ],
- 1000);
+ input?.animate?.(
+ [
+ {transform: 'scale(1)', easing: 'ease-out'},
+ {transform: 'scale(.75)', easing: 'ease-in'},
+ {transform: 'scale(1)'},
+ ],
+ 1000,
+ );
};
#clearListeners() {
@@ -72,7 +81,8 @@ export class MyPrettyInput extends LitElement {
this.#lastInput = null;
}
- static styles = css`/* playground-fold */
+ static styles = css`
+ /* playground-fold */
canvas {
border: 1px solid black;
}
@@ -81,5 +91,6 @@ export class MyPrettyInput extends LitElement {
display: block;
margin-block-start: 1em;
}
- /* playground-fold-end */`;
+ /* playground-fold-end */
+ `;
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts
index 13e84b3a0..23f7b3f42 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query-async/my-element.ts
@@ -1,12 +1,12 @@
-import { html, LitElement, css, PropertyValues } from 'lit';
-import { customElement, state, property, queryAsync } from 'lit/decorators.js';
+import {html, LitElement, css, PropertyValues} from 'lit';
+import {customElement, state, property, queryAsync} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@property({type: Boolean}) showCanvas = false;
@state() private canvasText = 'Hello World!';
// You can use any querySelector selector
- @queryAsync('#canvasId') private canvasEl!: Promise;
+ @queryAsync('#canvasId') private canvasEl!: Promise;
protected update(changed: PropertyValues) {
if (changed.has('showCanvas')) {
@@ -19,14 +19,14 @@ export class MyElement extends LitElement {
render() {
return html`
- ${
- this.showCanvas ?
- html` ` :
- html` this.showCanvas = true}>Show Canvas `
- }
+ ${this.showCanvas
+ ? html` `
+ : html` (this.showCanvas = true)}>
+ Show Canvas
+ `}
Enter text to draw in canvas:
-
+
`;
}
@@ -40,22 +40,23 @@ export class MyElement extends LitElement {
return;
}
- const ctx = canvasEl?.getContext("2d");
+ const ctx = canvasEl?.getContext('2d');
if (!ctx) {
return;
}
ctx.clearRect(0, 0, canvasEl.width, canvasEl.height);
- ctx.font = "50px Arial";
- ctx.fillText(this.canvasText,10,80);
+ ctx.font = '50px Arial';
+ ctx.fillText(this.canvasText, 10, 80);
}
private handleInput(event: Event) {
this.setCanvasText((event.target as HTMLInputElement).value);
}
- static styles = css`/* playground-fold */
+ static styles = css`
+ /* playground-fold */
canvas {
border: 1px solid black;
}
@@ -64,5 +65,6 @@ export class MyElement extends LitElement {
display: block;
margin-block-start: 1em;
}
- /* playground-fold-end */`;
+ /* playground-fold-end */
+ `;
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts
index 94f5b06af..141a000da 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-query/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement, css } from 'lit';
-import { customElement, state, query } from 'lit/decorators.js';
+import {html, LitElement, css} from 'lit';
+import {customElement, state, query} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -12,7 +12,7 @@ export class MyElement extends LitElement {
Enter text to draw in canvas:
-
+
`;
}
@@ -20,15 +20,15 @@ export class MyElement extends LitElement {
private setCanvasText(text: string) {
this.canvasText = text;
// Access the canvas element with this.canvasEl
- const ctx = this.canvasEl.getContext("2d");
+ const ctx = this.canvasEl.getContext('2d');
if (!ctx) {
return;
}
ctx.clearRect(0, 0, this.canvasEl.width, this.canvasEl.height);
- ctx.font = "50px Arial";
- ctx.fillText(this.canvasText,10,80);
+ ctx.font = '50px Arial';
+ ctx.fillText(this.canvasText, 10, 80);
}
private handleInput(event: Event) {
@@ -40,7 +40,8 @@ export class MyElement extends LitElement {
this.setCanvasText(this.canvasText);
}
- static styles = css`/* playground-fold */
+ static styles = css`
+ /* playground-fold */
canvas {
border: 1px solid black;
}
@@ -49,5 +50,6 @@ export class MyElement extends LitElement {
display: block;
margin-block-start: 1em;
}
- /* playground-fold-end */`;
+ /* playground-fold-end */
+ `;
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts
index 398013904..08ead3187 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/dom-ref/my-element.ts
@@ -1,6 +1,6 @@
-import { html, LitElement, css } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
-import { ref, createRef } from 'lit/directives/ref.js';
+import {html, LitElement, css} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
+import {ref, createRef} from 'lit/directives/ref.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -12,7 +12,7 @@ export class MyElement extends LitElement {
Enter text to draw in canvas:
-
+
`;
}
@@ -23,15 +23,20 @@ export class MyElement extends LitElement {
}
this.canvasText = text;
// Access the canvas element with this.canvasEl
- const ctx = this.canvasRef.value.getContext("2d");
+ const ctx = this.canvasRef.value.getContext('2d');
if (!ctx) {
return;
}
- ctx.clearRect(0, 0, this.canvasRef.value.width, this.canvasRef.value.height);
- ctx.font = "50px Arial";
- ctx.fillText(this.canvasText,10,80);
+ ctx.clearRect(
+ 0,
+ 0,
+ this.canvasRef.value.width,
+ this.canvasRef.value.height,
+ );
+ ctx.font = '50px Arial';
+ ctx.fillText(this.canvasText, 10, 80);
}
private handleInput(event: Event) {
@@ -43,7 +48,8 @@ export class MyElement extends LitElement {
this.setCanvasText(this.canvasText);
}
- static styles = css`/* playground-fold */
+ static styles = css`
+ /* playground-fold */
canvas {
border: 1px solid black;
}
@@ -52,5 +58,6 @@ export class MyElement extends LitElement {
display: block;
margin-block-start: 1em;
}
- /* playground-fold-end */`;
+ /* playground-fold-end */
+ `;
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts
index 33d8c1696..a04f3dcb9 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/event-listeners/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement } from 'lit';
-import { customElement, query, state } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement, query, state} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts
index 05456dd5d..890008c27 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/another-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement, css } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement, css} from 'lit';
+import {customElement} from 'lit/decorators.js';
@customElement('another-element')
export class AnotherElement extends LitElement {
@@ -9,4 +9,4 @@ export class AnotherElement extends LitElement {
Part 2
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html
index 09a583b4e..db7e424a3 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/index.html
@@ -9,4 +9,4 @@
}
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts
index f13ab63c8..ed21a7250 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/export-part/my-element.ts
@@ -1,10 +1,12 @@
-import { html, LitElement, css } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement, css} from 'lit';
+import {customElement} from 'lit/decorators.js';
import './another-element.js';
@customElement('my-element')
export class MyElement extends LitElement {
render() {
- return html` `;
+ return html` `;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts
index 61e34ff7a..17e73eee7 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/expressions/my-element.ts
@@ -1,5 +1,5 @@
-import { css, html, LitElement, PropertyValues } from 'lit';
-import { customElement, query, state } from 'lit/decorators.js';
+import {css, html, LitElement, PropertyValues} from 'lit';
+import {customElement, query, state} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -14,7 +14,8 @@ export class MyElement extends LitElement {
+ .value=${this.value}
+ />
@@ -52,10 +59,10 @@ export class MyElement extends LitElement {
}
static styles = css`
- /* playground-fold */
+ /* playground-fold */
label {
display: block;
}
- /* playground-fold-end */
+ /* playground-fold-end */
`;
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html
index f03ab07ca..3859cca22 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/index.html
@@ -1,4 +1,4 @@
Click either inside or outside this component with a box border
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts
index 5f575d42e..92d236477 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/global-listeners/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement, isServer, css } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
+import {html, LitElement, isServer, css} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -7,8 +7,12 @@ export class MyElement extends LitElement {
render() {
return html`
- ${!this.clickedOutside ? html`Something was clicked INSIDE this component
` : ''}
- ${this.clickedOutside ? html`Something was clicked OUTSIDE this component
` : ''}
+ ${!this.clickedOutside
+ ? html`Something was clicked INSIDE this component
`
+ : ''}
+ ${this.clickedOutside
+ ? html`Something was clicked OUTSIDE this component
`
+ : ''}
`;
}
@@ -38,11 +42,13 @@ export class MyElement extends LitElement {
this.clickedOutside = !path.includes(this);
};
- static styles = css`/* playground-fold */
+ static styles = css`
+ /* playground-fold */
:host {
display: inline-flex;
border: 1px solid black;
}
- /* playground-fold-end */`;
-}
\ No newline at end of file
+ /* playground-fold-end */
+ `;
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts
index e961fc484..f69bb69aa 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/host-listeners/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement, isServer } from 'lit';
-import { customElement, state } from 'lit/decorators.js';
+import {html, LitElement, isServer} from 'lit';
+import {customElement, state} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -8,7 +8,9 @@ export class MyElement extends LitElement {
render() {
return html`
Focus me!
- ${this.focusedWithin ? html`Something in this component was focused
` : ''}
+ ${this.focusedWithin
+ ? html`Something in this component was focused
`
+ : ''}
`;
}
@@ -30,4 +32,4 @@ export class MyElement extends LitElement {
#onFocusout() {
this.focusedWithin = false;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js
index 952c50945..ae778504a 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import-attributes/my-element.js
@@ -1,15 +1,11 @@
-import { html, LitElement } from 'lit';
-import styles from './styles.css' with { type: 'css' };
+import {html, LitElement} from 'lit';
+import styles from './styles.css' with {type: 'css'};
export class MyElement extends LitElement {
static styles = styles;
render() {
- return html`
-
- This should be red!
-
- `;
+ return html` This should be red!
`;
}
}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts
index 8e2671b95..30f7e44dd 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/another-component.ts
@@ -1,9 +1,9 @@
-import { html, LitElement } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators.js';
@customElement('another-component')
export class AnotherComponent extends LitElement {
render() {
return html`(I'm another component.) `;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts
index de5f2dccf..703e9859a 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/hello-world.ts
@@ -1,10 +1,10 @@
-import { html, LitElement } from 'lit';
-import { customElement } from 'lit/decorators.js';
-import './another-component.js'
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators.js';
+import './another-component.js';
@customElement('hello-world')
export class HelloWorld extends LitElement {
render() {
return html`Hello, world! `;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html
index c53974764..be6dad253 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/import/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html
index 5b273eb5d..af12c60f1 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/index.html
@@ -18,4 +18,4 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts
index f6ed8d2d6..d5e60dadf 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/inheriting-custom-props/my-element.ts
@@ -1,5 +1,5 @@
-import { html, LitElement, css } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement, css} from 'lit';
+import {customElement} from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
@@ -14,4 +14,4 @@ export class MyElement extends LitElement {
render() {
return html`This is in a shadow root!
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts
index b7a427e95..d7270029a 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/id-card.ts
@@ -1,20 +1,20 @@
-import { html, LitElement } from 'lit';
-import { customElement, property } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement, property} from 'lit/decorators.js';
@customElement('id-card')
export class IdCard extends LitElement {
@property() name = '';
- @property({ type: Number }) age = 0;
- @property({ type: Boolean }) programmer = false;
+ @property({type: Number}) age = 0;
+ @property({type: Boolean}) programmer = false;
render() {
return html`
${this.name}
Age: ${this.age}
-
+
Programmer
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html
index d5f0f24d5..f07c80f59 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts
index 0159d6911..e97a5cb10 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/pass-data-down/my-wallet.ts
@@ -1,12 +1,12 @@
-import { html, LitElement } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators.js';
import './id-card.js';
@customElement('my-wallet')
export class MyWallet extends LitElement {
render() {
return html`
-
+
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts
index 0feccc9d3..29cc9a9a9 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/id-card.ts
@@ -1,30 +1,30 @@
-import { html, LitElement } from 'lit';
-import { customElement, property } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement, property} from 'lit/decorators.js';
@customElement('id-card')
export class IdCard extends LitElement {
// Default attribute converter is string
@property() name = '';
// Number attribute converter converts attribtues to numbers
- @property({ type: Number }) age = 0;
+ @property({type: Number}) age = 0;
// Boolean attribute converter converts attribtues to boolean using
// .hasAttribute(). NOTE: boolean-attribute="false" will result in `true`
- @property({ type: Boolean }) programmer = false;
+ @property({type: Boolean}) programmer = false;
// You can also specify the attribute name
- @property({ type: Boolean, attribute: 'is-cool' }) isCool = false;
+ @property({type: Boolean, attribute: 'is-cool'}) isCool = false;
render() {
return html`
${this.name}
Age: ${this.age}
-
+
Programmer
-
+
Is Cool
`;
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html
index d5f0f24d5..f07c80f59 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts
index b88d3de0e..cacd8014d 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/reactive-properties/my-wallet.ts
@@ -1,12 +1,17 @@
-import { html, LitElement } from 'lit';
-import { customElement } from 'lit/decorators.js';
+import {html, LitElement} from 'lit';
+import {customElement} from 'lit/decorators.js';
import './id-card.js';
@customElement('my-wallet')
export class MyWallet extends LitElement {
render() {
return html`
-
+
Toggle fancy button active state
-
+
Active
@@ -35,10 +42,9 @@ export class MyButton extends LitElement {
/* playground-fold */
#toggleActive(e: InputEvent) {
- this.active = (e.target as HTMLInputElement).checked
+ this.active = (e.target as HTMLInputElement).checked;
}
-
constructor() {
super();
(MyButton.styles as any).replaceSync(getPluginStyles());
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts
index 9a1cddb7d..7340838bd 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/update-complete/my-element.ts
@@ -1,5 +1,5 @@
-import { css, html, LitElement } from 'lit';
-import { customElement, query, state } from 'lit/decorators.js';
+import {css, html, LitElement} from 'lit';
+import {customElement, query, state} from 'lit/decorators.js';
import {styleMap} from 'lit/directives/style-map.js';
@customElement('my-element')
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html
index 57a0c9aca..9a1b15c74 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/index.html
@@ -1,3 +1,3 @@
-
\ No newline at end of file
+
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts
index 8161cfaaf..dea9e13da 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/virtualizer/my-element.ts
@@ -14,8 +14,9 @@ export class MyItems extends LitElement {
have the lit-virtualizer element as a wrapper
-->
html`${i.text} `}>
+ .items=${this.data}
+ .renderItem=${(i: {text: string}) => html`${i.text} `}
+ >
`;
diff --git a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json
index 20ba04f9a..802d336ab 100644
--- a/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json
+++ b/packages/lit-dev-content/samples/articles/lit-cheat-sheet/with-logger.json
@@ -6,4 +6,4 @@
"content": "import {LitElement, html, css} from 'lit';\nimport {customElement} from 'lit/decorators.js';\nimport {SignalWatcher, signal, watch} from '@lit-labs/signals';\n\nconst log = signal([]);\n\nconst oldLog = window.console.log\nwindow.console.log = (...values: unknown[]) => {\n log.set([...log.get(), values]);\n oldLog(...values)\n};\n\nconst globalStyles = new CSSStyleSheet();\n\nglobalStyles.replaceSync(`body {\n display: flex;\n}\n \nbody > * {\n flex: 1\n}`)\n\ndocument.adoptedStyleSheets.push(globalStyles);\n\n@customElement('visual-logger')\nexport class MyElement extends SignalWatcher(LitElement) {\n render() {\n return html`\n \n
Log: \n
\n ${log.get().toReversed().map(val => html`
${val.join(' ')}
`)}\n
\n `;\n }\n \n static styles = css`\n #log {\n display: block;\n max-height: 100dvh;\n }\n \n p {\n margin: 0;\n font-family: monospace;\n }\n `;\n}"
}
}
-}
\ No newline at end of file
+}
diff --git a/packages/lit-dev-content/samples/examples/async-task/index.html b/packages/lit-dev-content/samples/examples/async-task/index.html
index 8099c92be..c1262ffc1 100644
--- a/packages/lit-dev-content/samples/examples/async-task/index.html
+++ b/packages/lit-dev-content/samples/examples/async-task/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/async-task/npm-info.ts b/packages/lit-dev-content/samples/examples/async-task/npm-info.ts
index 5175f0b5f..8da47aeff 100644
--- a/packages/lit-dev-content/samples/examples/async-task/npm-info.ts
+++ b/packages/lit-dev-content/samples/examples/async-task/npm-info.ts
@@ -54,13 +54,13 @@ export class NpmInfo extends LitElement {
${map(
Object.entries(pkg['dist-tags']),
- ([tag, version]) => html`${tag}: ${version} `
+ ([tag, version]) =>
+ html`${tag}: ${version} `,
)}
`,
- error: (e) => html`
- Error: ${(e as Error).message}
- `,
+ error: (e) =>
+ html` Error: ${(e as Error).message} `,
})}
`;
diff --git a/packages/lit-dev-content/samples/examples/async-task/npm.ts b/packages/lit-dev-content/samples/examples/async-task/npm.ts
index dc8311a73..57859d9a3 100644
--- a/packages/lit-dev-content/samples/examples/async-task/npm.ts
+++ b/packages/lit-dev-content/samples/examples/async-task/npm.ts
@@ -5,7 +5,7 @@ export interface NpmPackage {
export const fetchPackageInfo = async (
pkgName: string,
- signal: AbortSignal
+ signal: AbortSignal,
): Promise => {
// Artificial delay for demo purposes
await new Promise((r) => setTimeout(r, 1000));
diff --git a/packages/lit-dev-content/samples/examples/context-basics/index.html b/packages/lit-dev-content/samples/examples/context-basics/index.html
index f67442dfe..6463c58f2 100644
--- a/packages/lit-dev-content/samples/examples/context-basics/index.html
+++ b/packages/lit-dev-content/samples/examples/context-basics/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts b/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts
index 039c47be5..a7bedb929 100644
--- a/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-async-append/my-element.ts
@@ -2,8 +2,8 @@ import {LitElement, html} from 'lit';
import {customElement, state} from 'lit/decorators.js';
import {asyncAppend} from 'lit/directives/async-append.js';
-async function *tossCoins(count: number) {
- for (let i=0; i 0.5 ? 'Heads' : 'Tails';
await new Promise((r) => setTimeout(r, 1000));
}
@@ -11,12 +11,12 @@ async function *tossCoins(count: number) {
@customElement('my-element')
class MyElement extends LitElement {
-
@state()
private tosses = tossCoins(10);
render() {
- return html`
- ${asyncAppend(this.tosses, (v) => html`${v} `)} `;
+ return html`
+ ${asyncAppend(this.tosses, (v) => html`${v} `)}
+ `;
}
}
diff --git a/packages/lit-dev-content/samples/examples/directive-async-replace/index.html b/packages/lit-dev-content/samples/examples/directive-async-replace/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-async-replace/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-async-replace/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts b/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts
index 9b8f33cf7..54c30dfc5 100644
--- a/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-async-replace/my-element.ts
@@ -2,7 +2,7 @@ import {LitElement, html} from 'lit';
import {customElement, state} from 'lit/decorators.js';
import {asyncReplace} from 'lit/directives/async-replace.js';
-async function *countDown(count: number) {
+async function* countDown(count: number) {
while (count > 0) {
yield count--;
await new Promise((r) => setTimeout(r, 1000));
@@ -11,7 +11,6 @@ async function *countDown(count: number) {
@customElement('my-element')
class MyElement extends LitElement {
-
@state()
private timer = countDown(10);
diff --git a/packages/lit-dev-content/samples/examples/directive-cache/index.html b/packages/lit-dev-content/samples/examples/directive-cache/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-cache/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-cache/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts b/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts
index daa6e64ca..3ee0b1748 100644
--- a/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-cache/my-element.ts
@@ -2,12 +2,11 @@ import {LitElement, html} from 'lit';
import {customElement, property} from 'lit/decorators.js';
import {cache} from 'lit/directives/cache.js';
-const view1 = () => html`View 1: `;
-const view2 = () => html`View 2: `;
+const view1 = () => html`View 1: `;
+const view2 = () => html`View 2: `;
@customElement('my-element')
export class MyElement extends LitElement {
-
@property({type: Number})
selectedView = 1;
@@ -15,12 +14,14 @@ export class MyElement extends LitElement {
return html`
cache directive example
- Toggle View
+ Toggle View
+
- Un-cached (DOM re-created when template re-rendered):
- ${this.selectedView == 1 ? view1() : view2()}
+ Un-cached (DOM re-created when template re-rendered):
+ ${this.selectedView == 1 ? view1() : view2()}
+
- Cached (DOM cached and re-used when template re-rendered):
+ Cached (DOM cached and re-used when template re-rendered):
${cache(this.selectedView == 1 ? view1() : view2())}
`;
}
diff --git a/packages/lit-dev-content/samples/examples/directive-class-map/index.html b/packages/lit-dev-content/samples/examples/directive-class-map/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-class-map/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-class-map/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts b/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts
index 0098c9539..1c4644e66 100644
--- a/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-class-map/my-element.ts
@@ -4,7 +4,6 @@ import {classMap} from 'lit/directives/class-map.js';
@customElement('my-element')
export class MyElement extends LitElement {
-
static styles = css`
.enabled {
background: lightgreen;
@@ -27,19 +26,27 @@ export class MyElement extends LitElement {
const classes = {
enabled: this.enabled,
hidden: this.hidden,
- padded: true
+ padded: true,
};
return html`
classMap directive example
Classy text
-
+
-
+
Enabled
-
+
Hidden
`;
diff --git a/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts b/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts
index 94a72ff04..b529b2fbd 100644
--- a/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts
+++ b/packages/lit-dev-content/samples/examples/directive-guard/calculate-sha.ts
@@ -5,7 +5,9 @@ async function sha256(message: string) {
const msgBuffer = new TextEncoder().encode(message);
const hashBuffer = await crypto.subtle.digest('SHA-256', msgBuffer);
const hashArray = Array.from(new Uint8Array(hashBuffer));
- const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('');
+ const hashHex = hashArray
+ .map((b) => ('00' + b.toString(16)).slice(-2))
+ .join('');
// Add some artificial delay for demo purposes...
await new Promise((r) => setTimeout(() => r(), 1000));
return hashHex;
@@ -13,4 +15,4 @@ async function sha256(message: string) {
export const calculateSHA = (value: string) => {
return until(sha256(value), 'Calculating sha...');
-}
+};
diff --git a/packages/lit-dev-content/samples/examples/directive-guard/index.html b/packages/lit-dev-content/samples/examples/directive-guard/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-guard/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-guard/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts b/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts
index ca0461a70..f3736f206 100644
--- a/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-guard/my-element.ts
@@ -5,7 +5,6 @@ import {calculateSHA} from './calculate-sha.js';
@customElement('my-element')
export class MyElement extends LitElement {
-
@state()
private value: string = 'test string';
@@ -19,15 +18,17 @@ export class MyElement extends LitElement {
return html`
guard directive example
-
- Calculate
+
+ Calculate
The SHA for '${this.value}' is:
${guard([this.value], () => calculateSHA(this.value))}
-
+
- Incrementing the counter does not recalculate SHA:
- Increment: ${this.counter}
+ Incrementing the counter does not recalculate SHA:
+
+ Increment: ${this.counter}
+
`;
}
diff --git a/packages/lit-dev-content/samples/examples/directive-if-defined/index.html b/packages/lit-dev-content/samples/examples/directive-if-defined/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-if-defined/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-if-defined/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts b/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts
index 87d5e933b..153b711f4 100644
--- a/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-if-defined/my-element.ts
@@ -3,16 +3,15 @@ import {customElement, state, query} from 'lit/decorators.js';
import {ifDefined} from 'lit/directives/if-defined.js';
const imageInfo = {
- 'beach': { domain: 'picsum.photos', id: 100 },
- 'river': { domain: 'picsum.photos', id: 1015 },
- 'canyon': { domain: 'picsum.photos', id: 1016 },
+ beach: {domain: 'picsum.photos', id: 100},
+ river: {domain: 'picsum.photos', id: 1015},
+ canyon: {domain: 'picsum.photos', id: 1016},
};
type ImageKey = keyof typeof imageInfo;
@customElement('my-element')
class MyElement extends LitElement {
-
@state()
private imageName: ImageKey = 'beach';
@@ -26,14 +25,20 @@ class MyElement extends LitElement {
return html`
ifDefined directive example
- Type one of 'beach', 'river', or 'canyon':
-
+ Type one of 'beach', 'river', or 'canyon':
+
+
- Using ifDefined (src removed when undefined):
-
+ Using ifDefined (src removed when undefined):
+
+
- Without ifDefined (will 404 when undefined):
-
+ Without ifDefined (will 404 when undefined):
+
`;
}
diff --git a/packages/lit-dev-content/samples/examples/directive-live/index.html b/packages/lit-dev-content/samples/examples/directive-live/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-live/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-live/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-live/my-element.ts b/packages/lit-dev-content/samples/examples/directive-live/my-element.ts
index 165ba2f2b..0b8e7595d 100644
--- a/packages/lit-dev-content/samples/examples/directive-live/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-live/my-element.ts
@@ -4,7 +4,6 @@ import {live} from 'lit/directives/live.js';
@customElement('my-element')
class MyElement extends LitElement {
-
@state()
private data = {value: 'test'};
@@ -12,19 +11,23 @@ class MyElement extends LitElement {
private input!: HTMLInputElement;
render() {
-
return html`
live directive example
- Set this value to the inputs below.
-
- Commit
+ Set this value to the inputs below.
+
+ Commit
+
- With live: will update if out of sync with last rendered value
-
+ With live: will update if out of sync with last rendered value
+
+
- Without live: will not update if out of sync with last rendered value
-
+ Without live: will not update if out of sync with last rendered value
+
`;
}
diff --git a/packages/lit-dev-content/samples/examples/directive-ref/index.html b/packages/lit-dev-content/samples/examples/directive-ref/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-ref/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-ref/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts b/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts
index f4c9172e3..0ac1b866b 100644
--- a/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-ref/my-element.ts
@@ -2,11 +2,13 @@ import {LitElement, html, css} from 'lit';
import {customElement} from 'lit/decorators.js';
import {ref, createRef} from 'lit/directives/ref.js';
-const loremIpsum = Array(100).fill(0).map(() => 'Lorem ipsum dolor sit amet.').join(' ');
+const loremIpsum = Array(100)
+ .fill(0)
+ .map(() => 'Lorem ipsum dolor sit amet.')
+ .join(' ');
@customElement('my-element')
export class MyElement extends LitElement {
-
static styles = css`
.scroll {
height: 100px;
@@ -20,10 +22,11 @@ export class MyElement extends LitElement {
render() {
return html`
- Passing ref directive a Ref object that will hold the element in .value:
-
+ Passing ref directive a Ref object that will hold the element in
+ .value:
+
-
+
Passing ref directive a change callback
diff --git a/packages/lit-dev-content/samples/examples/directive-repeat/index.html b/packages/lit-dev-content/samples/examples/directive-repeat/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-repeat/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-repeat/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts b/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts
index fe70722d3..dc7761c5f 100644
--- a/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-repeat/my-element.ts
@@ -4,15 +4,14 @@ import {repeat} from 'lit/directives/repeat.js';
@customElement('my-element')
class MyElement extends LitElement {
-
@state()
private items = [
- {id: 0, name: "Justin"},
- {id: 1, name: "Steve"},
- {id: 2, name: "Kevin"},
- {id: 3, name: "Russell"},
- {id: 4, name: "Liz"},
- {id: 5, name: "Peter"},
+ {id: 0, name: 'Justin'},
+ {id: 1, name: 'Steve'},
+ {id: 2, name: 'Kevin'},
+ {id: 3, name: 'Russell'},
+ {id: 4, name: 'Liz'},
+ {id: 5, name: 'Peter'},
];
render() {
@@ -20,24 +19,39 @@ class MyElement extends LitElement {
repeat directive example
this.sort(1)}>Sort ascending
-
this.sort(-1)}>Sort descending
+
this.sort(-1)}>Sort descending
+
With keying (DOM including checkbox state moves with items):
+ ${repeat(
+ this.items,
+ (item) => item.id,
+ (item, index) =>
+ html`
+ ${index}: ${item.name}
+ `,
+ )}
+
+
- Without keying (items are re-used in place, checkbox state does not change):
+ Without keying (items are re-used in place, checkbox state does not
+ change):
-
`;
}
private sort(dir: number) {
- this.items = [...this.items.sort((a, b) => a.name.localeCompare(b.name) * dir)];
+ this.items = [
+ ...this.items.sort((a, b) => a.name.localeCompare(b.name) * dir),
+ ];
}
}
diff --git a/packages/lit-dev-content/samples/examples/directive-style-map/index.html b/packages/lit-dev-content/samples/examples/directive-style-map/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-style-map/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-style-map/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts b/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts
index 15d04e340..a0d5690da 100644
--- a/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-style-map/my-element.ts
@@ -4,7 +4,6 @@ import {styleMap} from 'lit/directives/style-map.js';
@customElement('my-element')
export class MyElement extends LitElement {
-
@property({type: Boolean})
enabled = true;
@@ -15,19 +14,27 @@ export class MyElement extends LitElement {
const styles = {
backgroundColor: this.enabled ? 'lightgreen' : 'transparent',
opacity: this.hidden ? '0.2' : '1',
- padding: '10px'
+ padding: '10px',
};
return html`
styleMap directive example
Hello style!
-
+
-
+
Enabled
-
+
Hidden
`;
diff --git a/packages/lit-dev-content/samples/examples/directive-template-content/index.html b/packages/lit-dev-content/samples/examples/directive-template-content/index.html
index 557c74d07..c487c72a7 100644
--- a/packages/lit-dev-content/samples/examples/directive-template-content/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-template-content/index.html
@@ -1,12 +1,14 @@
This is content stamped from an HTML <template>!
-
+
diff --git a/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts b/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts
index 28a8f97d9..e8aaa7dff 100644
--- a/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-template-content/my-element.ts
@@ -3,13 +3,14 @@ import {customElement} from 'lit/decorators.js';
import {templateContent} from 'lit/directives/template-content.js';
//
is located in index.html file
-const templateEl = document.querySelector('template#myContent') as HTMLTemplateElement;
+const templateEl = document.querySelector(
+ 'template#myContent',
+) as HTMLTemplateElement;
@customElement('my-element')
class MyElement extends LitElement {
-
render() {
- return html`
+ return html`
templateContent directive example
Here's some content from a template element:
${templateContent(templateEl)}
diff --git a/packages/lit-dev-content/samples/examples/directive-unsafe-html/index.html b/packages/lit-dev-content/samples/examples/directive-unsafe-html/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-unsafe-html/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-unsafe-html/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-unsafe-html/my-element.ts b/packages/lit-dev-content/samples/examples/directive-unsafe-html/my-element.ts
index 40a575a9e..34f880dc2 100644
--- a/packages/lit-dev-content/samples/examples/directive-unsafe-html/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-unsafe-html/my-element.ts
@@ -6,12 +6,10 @@ const markup = 'Some HTML to render. ';
@customElement('my-element')
class MyElement extends LitElement {
-
render() {
return html`
unsafeHTML directive example
- Look out, potentially unsafe HTML ahead:
- ${unsafeHTML(markup)}
+ Look out, potentially unsafe HTML ahead: ${unsafeHTML(markup)}
`;
}
}
diff --git a/packages/lit-dev-content/samples/examples/directive-unsafe-svg/index.html b/packages/lit-dev-content/samples/examples/directive-unsafe-svg/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-unsafe-svg/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-unsafe-svg/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-unsafe-svg/my-element.ts b/packages/lit-dev-content/samples/examples/directive-unsafe-svg/my-element.ts
index 4ed7f488b..58a4b6061 100644
--- a/packages/lit-dev-content/samples/examples/directive-unsafe-svg/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-unsafe-svg/my-element.ts
@@ -6,14 +6,19 @@ const svg = ' ';
@customElement('my-element')
class MyElement extends LitElement {
-
render() {
return html`
unsafeSVG directive example
Look out, potentially unsafe SVG ahead:
-
+
${unsafeSVG(svg)}
- `;
+
+ `;
}
}
diff --git a/packages/lit-dev-content/samples/examples/directive-until/index.html b/packages/lit-dev-content/samples/examples/directive-until/index.html
index fe1517255..f149c266f 100644
--- a/packages/lit-dev-content/samples/examples/directive-until/index.html
+++ b/packages/lit-dev-content/samples/examples/directive-until/index.html
@@ -1,5 +1,7 @@
diff --git a/packages/lit-dev-content/samples/examples/directive-until/my-element.ts b/packages/lit-dev-content/samples/examples/directive-until/my-element.ts
index c50451122..2807b3eeb 100644
--- a/packages/lit-dev-content/samples/examples/directive-until/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/directive-until/my-element.ts
@@ -5,11 +5,10 @@ import {until} from 'lit/directives/until.js';
const fetchData = async () => {
await new Promise((r) => setTimeout(() => r(), 2000));
return 'Lorem Ipsum';
-}
+};
@customElement('my-element')
class MyElement extends LitElement {
-
@state()
private content: Promise = fetchData();
diff --git a/packages/lit-dev-content/samples/examples/element-composition/index.html b/packages/lit-dev-content/samples/examples/element-composition/index.html
index 32dfee477..a7a3601a3 100644
--- a/packages/lit-dev-content/samples/examples/element-composition/index.html
+++ b/packages/lit-dev-content/samples/examples/element-composition/index.html
@@ -1,11 +1,11 @@
-
+
-
-
-
-
- lit-element code sample
-
+
+
+
+
+ lit-element code sample
+
diff --git a/packages/lit-dev-content/samples/examples/element-composition/my-article.ts b/packages/lit-dev-content/samples/examples/element-composition/my-article.ts
index 869aa1836..8020afc77 100644
--- a/packages/lit-dev-content/samples/examples/element-composition/my-article.ts
+++ b/packages/lit-dev-content/samples/examples/element-composition/my-article.ts
@@ -3,19 +3,18 @@ import {customElement} from 'lit/decorators.js';
@customElement('my-article')
class MyArticle extends LitElement {
- static styles =
- css`
- article {
- padding: 20px;
- font-family: 'Open Sans', sans-serif;
- }
- `
+ static styles = css`
+ article {
+ padding: 20px;
+ font-family: 'Open Sans', sans-serif;
+ }
+ `;
render() {
return html`
- Manage complexity by building large, complex components
- out of smaller, simpler components that do one thing well.
+ Manage complexity by building large, complex components out of
+ smaller, simpler components that do one thing well.
`;
diff --git a/packages/lit-dev-content/samples/examples/element-composition/my-footer.ts b/packages/lit-dev-content/samples/examples/element-composition/my-footer.ts
index 1fc3b6401..9fad6ec2a 100644
--- a/packages/lit-dev-content/samples/examples/element-composition/my-footer.ts
+++ b/packages/lit-dev-content/samples/examples/element-composition/my-footer.ts
@@ -3,23 +3,20 @@ import {customElement} from 'lit/decorators.js';
@customElement('my-footer')
class MyFooter extends LitElement {
- static styles =
- css`
- :host {
- position: absolute;
- bottom: 0;
- left: 0;
- right: 0;
- }
- footer {
- display: flex;
- justify-content: center;
- font-family: Manrope, sans-serif;
- }
- `;
+ static styles = css`
+ :host {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ }
+ footer {
+ display: flex;
+ justify-content: center;
+ font-family: Manrope, sans-serif;
+ }
+ `;
render() {
- return html`
-
- `;
+ return html` `;
}
}
diff --git a/packages/lit-dev-content/samples/examples/element-composition/my-header.ts b/packages/lit-dev-content/samples/examples/element-composition/my-header.ts
index 6b5736024..d9b4a2ecf 100644
--- a/packages/lit-dev-content/samples/examples/element-composition/my-header.ts
+++ b/packages/lit-dev-content/samples/examples/element-composition/my-header.ts
@@ -3,16 +3,13 @@ import {customElement} from 'lit/decorators.js';
@customElement('my-header')
class MyHeader extends LitElement {
- static styles =
- css`
- h1 {
- font-family: Manrope, sans-serif;
- text-align: center;
- }
- `;
+ static styles = css`
+ h1 {
+ font-family: Manrope, sans-serif;
+ text-align: center;
+ }
+ `;
render() {
- return html`
-
- `;
+ return html` `;
}
}
diff --git a/packages/lit-dev-content/samples/examples/expressions/my-element.ts b/packages/lit-dev-content/samples/examples/expressions/my-element.ts
index 9831ef940..779fa997d 100644
--- a/packages/lit-dev-content/samples/examples/expressions/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/expressions/my-element.ts
@@ -1,5 +1,5 @@
-import { LitElement, html } from 'lit';
-import { customElement, property } from 'lit/decorators.js';
+import {LitElement, html} from 'lit';
+import {customElement, property} from 'lit/decorators.js';
@customElement('my-element')
class MyElement extends LitElement {
diff --git a/packages/lit-dev-content/samples/examples/full-component/index.html b/packages/lit-dev-content/samples/examples/full-component/index.html
index 45a5f2c8f..3d8e53ee1 100644
--- a/packages/lit-dev-content/samples/examples/full-component/index.html
+++ b/packages/lit-dev-content/samples/examples/full-component/index.html
@@ -1,4 +1,4 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/packages/lit-dev-content/samples/examples/properties-custom-converter/my-element.ts b/packages/lit-dev-content/samples/examples/properties-custom-converter/my-element.ts
index 82a8ffaac..789eb088c 100644
--- a/packages/lit-dev-content/samples/examples/properties-custom-converter/my-element.ts
+++ b/packages/lit-dev-content/samples/examples/properties-custom-converter/my-element.ts
@@ -1,26 +1,24 @@
-import { LitElement, html} from "lit";
+import {LitElement, html} from 'lit';
import {customElement, property} from 'lit/decorators.js';
@customElement('my-element')
class MyElement extends LitElement {
@property({
converter: (attrValue: string | null) => {
- if (attrValue)
- return new Date(attrValue);
- else
- return undefined;
- }
+ if (attrValue) return new Date(attrValue);
+ else return undefined;
+ },
})
date?: Date;
render() {
return html`
${this.date
- ? html`Date is
+ ? html`
+ Date is
${this.date.toLocaleDateString()}
`
- : 'No date set'
- }
+ : 'No date set'}
`;
}
}
diff --git a/packages/lit-dev-content/samples/examples/properties-has-changed/date-display.ts b/packages/lit-dev-content/samples/examples/properties-has-changed/date-display.ts
index 55396e65e..60750b1e7 100644
--- a/packages/lit-dev-content/samples/examples/properties-has-changed/date-display.ts
+++ b/packages/lit-dev-content/samples/examples/properties-has-changed/date-display.ts
@@ -1,4 +1,4 @@
-import { LitElement, html, PropertyValues} from "lit";
+import {LitElement, html, PropertyValues} from 'lit';
import {customElement, property, query} from 'lit/decorators.js';
import {isSameDate} from './date-utils.js';
@@ -9,7 +9,7 @@ class DateDisplay extends LitElement {
// each Date is a new object
hasChanged: (value?: Date, oldValue?: Date) => {
return !isSameDate(value, oldValue);
- }
+ },
})
date?: Date;
@@ -18,8 +18,8 @@ class DateDisplay extends LitElement {
frames = [
{backgroundColor: '#fff'},
- {backgroundColor: '#324fff' },
- {backgroundColor: '#fff'}
+ {backgroundColor: '#324fff'},
+ {backgroundColor: '#fff'},
];
render() {
diff --git a/packages/lit-dev-content/samples/examples/properties-has-changed/date-utils.ts b/packages/lit-dev-content/samples/examples/properties-has-changed/date-utils.ts
index 5b0fa5f04..1350e8084 100644
--- a/packages/lit-dev-content/samples/examples/properties-has-changed/date-utils.ts
+++ b/packages/lit-dev-content/samples/examples/properties-has-changed/date-utils.ts
@@ -11,5 +11,9 @@ export function isSameDate(date1?: Date, date2?: Date) {
* in the local time zone, given a UTC Date object as returned by input type="date".
*/
export function localDateFromUTC(utcDate: Date) {
- return new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate());
+ return new Date(
+ utcDate.getUTCFullYear(),
+ utcDate.getUTCMonth(),
+ utcDate.getUTCDate(),
+ );
}
diff --git a/packages/lit-dev-content/samples/examples/properties-has-changed/index.html b/packages/lit-dev-content/samples/examples/properties-has-changed/index.html
index dbfd8e61c..9ffa79602 100644
--- a/packages/lit-dev-content/samples/examples/properties-has-changed/index.html
+++ b/packages/lit-dev-content/samples/examples/properties-has-changed/index.html
@@ -11,3 +11,4 @@
+