-
Notifications
You must be signed in to change notification settings - Fork 955
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
New syntax and main module #398
Conversation
I still think lit-html should try to set properties falling back to attributes without any special syntax. Same behavior as preact. html`<div className="foo"></div>` That sets the property. html`<div class="foo"></div>` And this sets the attribute. |
With this change, do you see any issues with adoption when properties are prefixed:
But the boolean attribute syntax is postfixed:
The new property syntax seems to make sense, but mixed positional syntax seems like it would be harder to coach into other people's workflow. Looking forward to implementing this in my team's growing collection of |
Let's keep discussion of the options to #399 |
docs-src/guide/01-getting-started.md
Outdated
``` | ||
|
||
The path to use depends on where you've installed lit-html to. Browsers only support importing other modules by path, not by package name, so without other tools involved, you'll have to use paths. | ||
|
||
If you use some tool than can convert package names into paths, then you can import by path: | ||
If you use a tool than converts package names into paths, then you can import by path: |
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.
typo: tha{n => t}
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.
done
docs/guide/getting-started.html
Outdated
@@ -3,7 +3,6 @@ | |||
|
|||
<html> | |||
<head> | |||
<title>Getting Started</title> |
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.
All the titles are gone, is that on purpose? (I honestly don't know how the documentation works, this just caught my eye)
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.
Good catch. It's a problem with the generator
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.
Just a few nits and a general point: the separation of core
and lit-html
feels a bit arbitrary and duplicative. Why is there an html
tag function in core
for example? If we really think it's important to maintain this basic "unopinionated" version it should probably still be mentioned in the documentation; however, I'd suggest not bothering with this distinction and removing the extra module and (admittedly small) duplication.
* Property bindings: Any type of value | ||
* Event handler bindings: Event handler functions only | ||
* Text content bindings: TemplateResults, Nodes. Other types converted to strings. | ||
Expressions can occur text content or in attribute value positions. |
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.
Expressions can occur in text content
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.
done
src/lit-html.ts
Outdated
* To update a container with new values, reevaluate the template literal and | ||
* call `render` with the new result. | ||
* Attribute names in lit-html templates preserve case, so properties are case | ||
* sensitive. If an |
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.
formatting
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.
done
src/lit-html.ts
Outdated
* | ||
* "\0-\x1F\x7F-\x9F" are Unicode control characters | ||
* Event handlers are sset by prefixing an attribute name with `on-`. |
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.
typo: sset => set
Change on-
to @
right?
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.
done
src/lit-html.ts
Outdated
|
||
/** | ||
* A placeholder for a dynamic expression in an HTML template. | ||
* html`<button on-click=${(e)=> this.onClickHandler(e)}>Buy Now</button>` |
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.
on-
to @
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.
done
src/lit-html.ts
Outdated
* There are two built-in part types: AttributePart and NodePart. NodeParts | ||
* always represent a single dynamic expression, while AttributeParts may | ||
* represent as many expressions are contained in the attribute. | ||
* Boolean attributes are set by appending `?` to an attribute name. |
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.
Change appending to prepending
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.
done
src/lit-html.ts
Outdated
* TODO(justinfagnani): That requirement is a little fragile. A | ||
* TemplateInstance could instead be more careful about which values it gives | ||
* to Part.update(). | ||
* html`<input type="checkbox" checked?=${value}>` |
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.
checked?
to ?checked
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.
done
@sorvell regarding the separation / duplication of core and lit-html: I'm open to merging core back into lit-html (and possibly vending a |
@sorvell PTAL |
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.
LGTM
e715f3c
to
ad7b5ca
Compare
Why did you remove so much documentation from the README.md? (See deletions from Lines 61–427). |
* Rename lit-html.ts to core.ts * Add new lit-html.ts with lit-extended like syntax. * Update README * Update docs * Deprecate lit-extended * Change event handlers to a @-prefix and boolean attributes to a ?-prefix.
This PR adds a new syntax that's like lit-extended, but defaults to setting attributes and requires opting-in to setting properties.
Properties are set with a
.
prefix:The new syntax is the main module of the package now. The unopinionated core has been moved to core.js and the new syntax is in lit-html.js
lit-extended is deprecated and will be removed before 1.0.
Fixes #399