-
Notifications
You must be signed in to change notification settings - Fork 879
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
Conversation
|
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultslit-element-list
render
update
update-reflect
lit-html-kitchen-sink
render
update
nop-update
lit-html-repeat
render
update
lit-html-template-heavy
render
update
reactive-element-list
render
update
update-reflect
|
2d4d0c1
to
049b1dc
Compare
packages/lit-html/src/lit-html.ts
Outdated
* const header = (title: string) => html`<h1>${title}</h1>`; | ||
* ``` | ||
* | ||
* The `html` tag takes the literal strings and embedded expression values for |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
packages/lit-html/src/lit-html.ts
Outdated
@@ -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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
Addresses github issue: #1883
Context
Documenting lit-html's
html
andnothing
. 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!