Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional documentation for html and nothing #2162

Merged
merged 3 commits into from
Sep 19, 2021
Merged

Conversation

AndrewJakubowicz
Copy link
Contributor

@AndrewJakubowicz AndrewJakubowicz commented Sep 16, 2021

Addresses github issue: #1883

Context

Documenting lit-html's html and nothing. The API documentation is sparse so I've borrowed heavily from the original lit-html polymer website.

Let me know if there is too much (especially in the html tag case) and if we only want to keep a smaller amount or something different. Intent was to share that there isn't string concatenation going on under the hood.

Identified as currently on lit.dev there is minimal documentation and they are heavily used in Lit: https://lit.dev/docs/api/templates/

Testing

Tested with mouse over in VsCode.

Thank you!

@changeset-bot
Copy link

changeset-bot bot commented Sep 16, 2021

⚠️ No Changeset found

Latest commit: 7ac4769

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@google-cla google-cla bot added the cla: yes label Sep 16, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Sep 16, 2021

📊 Tachometer Benchmark Results

Summary

nop-update

  • lit-html-kitchen-sink: unsure 🔍 -0% - +5% (-0.04ms - +1.81ms)
    this-change vs tip-of-tree

render

  • lit-element-list: unsure 🔍 -3% - +2% (-2.87ms - +2.43ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -4% - +2% (-1.95ms - +1.07ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -4% - +5% (-0.56ms - +0.74ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -3% - +3% (-1.91ms - +1.87ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -1% - +3% (-0.52ms - +2.47ms)
    this-change vs tip-of-tree

update

  • lit-element-list: unsure 🔍 -2% - +3% (-15.84ms - +27.99ms)
    this-change vs tip-of-tree
  • lit-html-kitchen-sink: unsure 🔍 -4% - +3% (-4.75ms - +3.99ms)
    this-change vs tip-of-tree
  • lit-html-repeat: unsure 🔍 -0% - +4% (-0.63ms - +15.44ms)
    this-change vs tip-of-tree
  • lit-html-template-heavy: unsure 🔍 -3% - +1% (-4.60ms - +2.22ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -2% - +2% (-17.51ms - +18.88ms)
    this-change vs tip-of-tree

update-reflect

  • lit-element-list: unsure 🔍 -1% - +3% (-12.82ms - +30.08ms)
    this-change vs tip-of-tree
  • reactive-element-list: unsure 🔍 -2% - +2% (-18.69ms - +17.99ms)
    this-change vs tip-of-tree

Results

lit-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
112.32ms - 116.58ms-unsure 🔍
-3% - +2%
-2.87ms - +2.43ms
faster ✔
20% - 24%
29.48ms - 35.14ms
tip-of-tree
tip-of-tree
113.09ms - 116.25msunsure 🔍
-2% - +3%
-2.43ms - +2.87ms
-faster ✔
20% - 23%
29.64ms - 34.53ms
previous-release
previous-release
144.89ms - 148.62msslower ❌
25% - 31%
29.48ms - 35.14ms
slower ❌
26% - 30%
29.64ms - 34.53ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
971.53ms - 1001.69ms-unsure 🔍
-2% - +3%
-15.84ms - +27.99ms
faster ✔
4% - 8%
45.94ms - 88.76ms
tip-of-tree
tip-of-tree
964.64ms - 996.44msunsure 🔍
-3% - +2%
-27.99ms - +15.84ms
-faster ✔
5% - 9%
51.43ms - 95.42ms
previous-release
previous-release
1038.76ms - 1069.16msslower ❌
5% - 9%
45.94ms - 88.76ms
slower ❌
5% - 10%
51.43ms - 95.42ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
997.65ms - 1028.38ms-unsure 🔍
-1% - +3%
-12.82ms - +30.08ms
faster ✔
3% - 7%
32.26ms - 76.32ms
tip-of-tree
tip-of-tree
989.42ms - 1019.35msunsure 🔍
-3% - +1%
-30.08ms - +12.82ms
-faster ✔
4% - 8%
41.16ms - 84.68ms
previous-release
previous-release
1051.51ms - 1083.09msslower ❌
3% - 8%
32.26ms - 76.32ms
slower ❌
4% - 8%
41.16ms - 84.68ms
-
lit-html-kitchen-sink

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
47.66ms - 49.69ms-unsure 🔍
-4% - +2%
-1.95ms - +1.07ms
faster ✔
11% - 17%
6.27ms - 9.76ms
tip-of-tree
tip-of-tree
48.00ms - 50.23msunsure 🔍
-2% - +4%
-1.07ms - +1.95ms
-faster ✔
10% - 16%
5.77ms - 9.38ms
previous-release
previous-release
55.28ms - 58.11msslower ❌
13% - 20%
6.27ms - 9.76ms
slower ❌
12% - 19%
5.77ms - 9.38ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
115.80ms - 121.81ms-unsure 🔍
-4% - +3%
-4.75ms - +3.99ms
faster ✔
2% - 9%
2.96ms - 11.04ms
tip-of-tree
tip-of-tree
116.01ms - 122.37msunsure 🔍
-3% - +4%
-3.99ms - +4.75ms
-faster ✔
2% - 9%
2.45ms - 10.79ms
previous-release
previous-release
123.11ms - 128.51msslower ❌
2% - 9%
2.96ms - 11.04ms
slower ❌
2% - 9%
2.45ms - 10.79ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
37.89ms - 39.33ms-unsure 🔍
-0% - +5%
-0.04ms - +1.81ms
unsure 🔍
-5% - +3%
-2.07ms - +1.21ms
tip-of-tree
tip-of-tree
37.14ms - 38.32msunsure 🔍
-5% - +0%
-1.81ms - +0.04ms
-unsure 🔍
-7% - +1%
-2.90ms - +0.27ms
previous-release
previous-release
37.57ms - 40.52msunsure 🔍
-3% - +5%
-1.21ms - +2.07ms
unsure 🔍
-1% - +8%
-0.27ms - +2.90ms
-
lit-html-repeat

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
14.72ms - 15.84ms-unsure 🔍
-4% - +5%
-0.56ms - +0.74ms
faster ✔
5% - 13%
0.84ms - 2.15ms
tip-of-tree
tip-of-tree
14.86ms - 15.51msunsure 🔍
-5% - +4%
-0.74ms - +0.56ms
-faster ✔
7% - 12%
1.12ms - 2.05ms
previous-release
previous-release
16.43ms - 17.11msslower ❌
5% - 14%
0.84ms - 2.15ms
slower ❌
7% - 14%
1.12ms - 2.05ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
429.80ms - 443.24ms-unsure 🔍
-0% - +4%
-0.63ms - +15.44ms
faster ✔
28% - 31%
171.33ms - 193.41ms
tip-of-tree
tip-of-tree
424.71ms - 433.52msunsure 🔍
-4% - +0%
-15.44ms - +0.63ms
-faster ✔
29% - 32%
179.97ms - 199.58ms
previous-release
previous-release
610.13ms - 627.65msslower ❌
39% - 45%
171.33ms - 193.41ms
slower ❌
42% - 47%
179.97ms - 199.58ms
-
lit-html-template-heavy

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
70.18ms - 73.17ms-unsure 🔍
-3% - +3%
-1.91ms - +1.87ms
faster ✔
14% - 18%
11.66ms - 15.99ms
tip-of-tree
tip-of-tree
70.53ms - 72.86msunsure 🔍
-3% - +3%
-1.87ms - +1.91ms
-faster ✔
14% - 18%
11.85ms - 15.76ms
previous-release
previous-release
83.93ms - 87.07msslower ❌
16% - 23%
11.66ms - 15.99ms
slower ❌
16% - 22%
11.85ms - 15.76ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
145.90ms - 150.53ms-unsure 🔍
-3% - +1%
-4.60ms - +2.22ms
faster ✔
11% - 15%
19.09ms - 25.73ms
tip-of-tree
tip-of-tree
146.90ms - 151.90msunsure 🔍
-2% - +3%
-2.22ms - +4.60ms
-faster ✔
11% - 14%
17.77ms - 24.68ms
previous-release
previous-release
168.24ms - 173.00msslower ❌
13% - 18%
19.09ms - 25.73ms
slower ❌
12% - 17%
17.77ms - 24.68ms
-
reactive-element-list

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
76.05ms - 77.79ms-unsure 🔍
-1% - +3%
-0.52ms - +2.47ms
unsure 🔍
-3% - +2%
-2.10ms - +1.70ms
tip-of-tree
tip-of-tree
74.73ms - 77.16msunsure 🔍
-3% - +1%
-2.47ms - +0.52ms
-unsure 🔍
-4% - +1%
-3.26ms - +0.91ms
previous-release
previous-release
75.43ms - 78.81msunsure 🔍
-2% - +3%
-1.70ms - +2.10ms
unsure 🔍
-1% - +4%
-0.91ms - +3.26ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
982.07ms - 1006.59ms-unsure 🔍
-2% - +2%
-17.51ms - +18.88ms
unsure 🔍
-1% - +2%
-13.64ms - +21.36ms
tip-of-tree
tip-of-tree
980.19ms - 1007.09msunsure 🔍
-2% - +2%
-18.88ms - +17.51ms
-unsure 🔍
-2% - +2%
-15.18ms - +21.53ms
previous-release
previous-release
977.98ms - 1002.96msunsure 🔍
-2% - +1%
-21.36ms - +13.64ms
unsure 🔍
-2% - +2%
-21.53ms - +15.18ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
1051.66ms - 1077.59ms-unsure 🔍
-2% - +2%
-18.69ms - +17.99ms
unsure 🔍
-1% - +2%
-14.67ms - +19.76ms
tip-of-tree
tip-of-tree
1052.01ms - 1077.95msunsure 🔍
-2% - +2%
-17.99ms - +18.69ms
-unsure 🔍
-1% - +2%
-14.32ms - +20.12ms
previous-release
previous-release
1050.76ms - 1073.41msunsure 🔍
-2% - +1%
-19.76ms - +14.67ms
unsure 🔍
-2% - +1%
-20.12ms - +14.32ms
-

tachometer-reporter-action v2 for Benchmarks

* const header = (title: string) => html`<h1>${title}</h1>`;
* ```
*
* The `html` tag takes the literal strings and embedded expression values for
Copy link
Member

@aomarks aomarks Sep 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this text come from lit.dev, or is it new?

It does seem like there's a downside to having too detailed documentation here. Otherwise we are maintaining the same documentation in two different places, which will definitely get out of sync.

I wonder if we should do something a little more concise, and then link to the relevant lit.dev section?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't think we need to describe how this works. I think we might hit a couple of points like:

  • this returns a description of the DOM to render as a value
  • Maybe that the value is a TemplateResult (but even that's pretty drilled in)
  • It captures the expression values and the static template strings
  • The result needs to be passed to render() to do anything
  • If a template result comes from the same expression as a previously rendered result, it's updated instead of replaced
  • Point to the template docs on lit.dev

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! Do we have this info on lit.dev (I couldn't find it). My reference was: https://lit-html.polymer-project.org/guide/writing-templates

Is the plan that lit.dev contains all the documentation for various packages?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, lit.dev is completely replacing the other sites.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened issue: lit/lit.dev#504, since not sure if we have a lit.dev location for these concepts yet.

Made much more succinct in follow up commit. Thank you!

@@ -327,6 +336,19 @@ export const noChange = Symbol.for('lit-noChange');

/**
* A sentinel value that signals a ChildPart to fully clear its content.
*
* The values `undefined`, `null`, and the empty string `''` all render an empty
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed in Lit 2. In child expressions, undefined, null, '', and nothing all render the same thing now - no nodes at all. In attribute expressions undefined, etc., will render an empty string and nothing will remove the attribute. In property expressions nothing becomes undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incredible info thank you. Will add.

@justinfagnani justinfagnani merged commit 791acb5 into main Sep 19, 2021
@justinfagnani justinfagnani deleted the expand-lit2-docs2 branch September 19, 2021 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants