Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AndrewJakubowicz
Copy link
Contributor

Issue: #189
RFC: lit/rfcs#21
Full prototype PR: #3984

Context

This is similar in spirit to #4088, where there is a runtime DEV_MODE check in lit-html that the compiler needs to handle.

Initially, handling by marking the templates as uncompilable such that the check remains in runtime.
In the future will add diagnostics to these cases.

Fix

Take the same logic as lit-html https://github.com/lit/lit/blob/lit-html%402.8.0/packages/lit-html/src/lit-html.ts#L893-L911, and use it to mark a template as uncompilable.

Test plan

Tested by using the lit-html_test tests, and ensuring the invalid goldens do not compile.

Future work is adding diagnostics to the compiler.

@changeset-bot
Copy link

changeset-bot bot commented Aug 14, 2023

🦋 Changeset detected

Latest commit: 11e01a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 14, 2023

📊 Tachometer Benchmark Results

Summary

nop-update

  • this-change, tip-of-tree, previous-release: unsure 🔍 -3% - +9% (-0.67ms - +1.84ms)
    this-change vs tip-of-tree

render

  • this-change: 69.14ms - 72.90ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -7% - +3% (-1.88ms - +0.84ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -1% - +2% (-0.74ms - +1.00ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -1% - +2% (-0.65ms - +0.95ms)
    this-change vs tip-of-tree

update

  • this-change: 751.79ms - 765.89ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -6% - +6% (-4.45ms - +4.38ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -2% - +1% (-2.35ms - +1.13ms)
    this-change vs tip-of-tree
  • this-change, tip-of-tree, previous-release: unsure 🔍 -1% - +1% (-5.76ms - +5.73ms)
    this-change vs tip-of-tree

update-reflect

  • this-change: 725.17ms - 732.92ms
  • this-change, tip-of-tree, previous-release: unsure 🔍 -0% - +1% (-0.11ms - +9.19ms)
    this-change vs tip-of-tree

Results

this-change

render

VersionAvg timevs
69.14ms - 72.90ms-

update

VersionAvg timevs
751.79ms - 765.89ms-

update-reflect

VersionAvg timevs
725.17ms - 732.92ms-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
26.66ms - 28.48ms-unsure 🔍
-7% - +3%
-1.88ms - +0.84ms
unsure 🔍
-6% - +3%
-1.57ms - +0.72ms
tip-of-tree
tip-of-tree
27.08ms - 29.10msunsure 🔍
-3% - +7%
-0.84ms - +1.88ms
-unsure 🔍
-4% - +5%
-1.13ms - +1.32ms
previous-release
previous-release
27.30ms - 28.69msunsure 🔍
-3% - +6%
-0.72ms - +1.57ms
unsure 🔍
-5% - +4%
-1.32ms - +1.13ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
69.95ms - 75.58ms-unsure 🔍
-6% - +6%
-4.45ms - +4.38ms
unsure 🔍
-6% - +4%
-4.63ms - +2.68ms
tip-of-tree
tip-of-tree
69.40ms - 76.21msunsure 🔍
-6% - +6%
-4.38ms - +4.45ms
-unsure 🔍
-7% - +4%
-5.06ms - +3.19ms
previous-release
previous-release
71.41ms - 76.07msunsure 🔍
-4% - +6%
-2.68ms - +4.63ms
unsure 🔍
-4% - +7%
-3.19ms - +5.06ms
-

nop-update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
19.18ms - 21.11ms-unsure 🔍
-3% - +9%
-0.67ms - +1.84ms
unsure 🔍
-7% - +6%
-1.35ms - +1.17ms
tip-of-tree
tip-of-tree
18.76ms - 20.36msunsure 🔍
-9% - +3%
-1.84ms - +0.67ms
-unsure 🔍
-9% - +2%
-1.82ms - +0.46ms
previous-release
previous-release
19.43ms - 21.04msunsure 🔍
-6% - +7%
-1.17ms - +1.35ms
unsure 🔍
-2% - +9%
-0.46ms - +1.82ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
50.19ms - 51.46ms-unsure 🔍
-1% - +2%
-0.74ms - +1.00ms
unsure 🔍
-1% - +2%
-0.47ms - +1.25ms
tip-of-tree
tip-of-tree
50.10ms - 51.29msunsure 🔍
-2% - +1%
-1.00ms - +0.74ms
-unsure 🔍
-1% - +2%
-0.57ms - +1.09ms
previous-release
previous-release
49.85ms - 51.02msunsure 🔍
-2% - +1%
-1.25ms - +0.47ms
unsure 🔍
-2% - +1%
-1.09ms - +0.57ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
105.78ms - 108.62ms-unsure 🔍
-2% - +1%
-2.35ms - +1.13ms
unsure 🔍
-3% - +1%
-2.96ms - +1.18ms
tip-of-tree
tip-of-tree
106.79ms - 108.82msunsure 🔍
-1% - +2%
-1.13ms - +2.35ms
-unsure 🔍
-2% - +1%
-2.11ms - +1.54ms
previous-release
previous-release
106.58ms - 109.61msunsure 🔍
-1% - +3%
-1.18ms - +2.96ms
unsure 🔍
-1% - +2%
-1.54ms - +2.11ms
-
this-change, tip-of-tree, previous-release

render

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
44.85ms - 46.06ms-unsure 🔍
-1% - +2%
-0.65ms - +0.95ms
unsure 🔍
-1% - +3%
-0.56ms - +1.18ms
tip-of-tree
tip-of-tree
44.79ms - 45.83msunsure 🔍
-2% - +1%
-0.95ms - +0.65ms
-unsure 🔍
-1% - +2%
-0.65ms - +0.98ms
previous-release
previous-release
44.52ms - 45.77msunsure 🔍
-3% - +1%
-1.18ms - +0.56ms
unsure 🔍
-2% - +1%
-0.98ms - +0.65ms
-

update

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
768.38ms - 776.74ms-unsure 🔍
-1% - +1%
-5.76ms - +5.73ms
unsure 🔍
-1% - +1%
-4.01ms - +7.61ms
tip-of-tree
tip-of-tree
768.63ms - 776.52msunsure 🔍
-1% - +1%
-5.73ms - +5.76ms
-unsure 🔍
-0% - +1%
-3.83ms - +7.46ms
previous-release
previous-release
766.72ms - 774.80msunsure 🔍
-1% - +1%
-7.61ms - +4.01ms
unsure 🔍
-1% - +0%
-7.46ms - +3.83ms
-

update-reflect

VersionAvg timevs this-change
vs tip-of-tree
tip-of-tree
vs previous-release
previous-release
this-change
770.35ms - 776.90ms-unsure 🔍
-0% - +1%
-0.11ms - +9.19ms
unsure 🔍
-0% - +1%
-0.27ms - +8.52ms
tip-of-tree
tip-of-tree
765.79ms - 772.38msunsure 🔍
-1% - +0%
-9.19ms - +0.11ms
-unsure 🔍
-1% - +1%
-4.82ms - +4.00ms
previous-release
previous-release
766.57ms - 772.43msunsure 🔍
-1% - +0%
-8.52ms - +0.27ms
unsure 🔍
-1% - +1%
-4.00ms - +4.82ms
-

tachometer-reporter-action v2 for Benchmarks

return false;
}
if (
/^(?:textarea|template)$/i!.test(node.tagName) &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

This regex works, but it's somewhat tricky! tagName is always all caps, so we don't need to worry about that. A regexp can be faster if it doesn't have to ignore case, so consider writing it with all caps. But since this code isn't that performance sensitive, consider just checking membership in a set.

Breaking that part of the conditional out into a local variable also lets us name it, which is helpful for documentation.

Looking at the HTML spec, for elements with a Text content model, I wonder if we should also check for <title>, <style>, <rp>, and an <option> with a label attribute but not a value attribute

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this something to improve in lit-html as well (regarding the other elements)?

I can refactor compiler.

@AndrewJakubowicz AndrewJakubowicz merged commit 43f96b0 into main Aug 15, 2023
@AndrewJakubowicz AndrewJakubowicz deleted the template-textarea-devmode branch August 15, 2023 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants