-
Notifications
You must be signed in to change notification settings - Fork 881
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
[reactive-element] Add queryAssignedElements decorator #2327
Conversation
🦋 Changeset detectedLatest commit: b3dae4b The changes in this PR will be included in the next version bump. 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 |
📊 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
|
11899cc
to
759c823
Compare
packages/reactive-element/src/decorators/query-assigned-elements.ts
Outdated
Show resolved
Hide resolved
9b8224b
to
d5d4506
Compare
if ( | ||
propAssignment && | ||
ts.isPropertyAssignment(propAssignment) && | ||
ts.isStringLiteral(propAssignment.initializer) |
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.
Should probably throw if it's not a string literal, because it could also be a variable and we'd silently ignore that here.
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 thank you!
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.
Actually just occured to me that selector
could be used as-is whatever kind of node it is, since it just goes directly into the filter
arguments, right?
And you could maybe also handle slot
being an identifier or whatever too by generating `slot[name=${node}]`
in the case that it's not a string?
575b2e7
to
51b8df7
Compare
packages/reactive-element/src/decorators/query-assigned-elements.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Show resolved
Hide resolved
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Outdated
Show resolved
Hide resolved
4097a4e
to
07417c2
Compare
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Show resolved
Hide resolved
34fb99c
to
6149cbf
Compare
367cc64
to
863ecc0
Compare
Tests are passing. The only tests failing is something to do with Sauce not connecting:
I think this is unrelated to my changes. |
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 great! Awesome to do get the transformer code in too.
if ( | ||
propAssignment && | ||
ts.isPropertyAssignment(propAssignment) && | ||
ts.isStringLiteral(propAssignment.initializer) |
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.
Actually just occured to me that selector
could be used as-is whatever kind of node it is, since it just goes directly into the filter
arguments, right?
And you could maybe also handle slot
being an identifier or whatever too by generating `slot[name=${node}]`
in the case that it's not a string?
…signedElements Add references to the new internal decorator across the monorepo packages.
`slot` instead of `slotName`. Fix up copy pasted tests such that they are more modern, remove unused pieces. Update the transformer tests.
In this change made the transformer far more flexible. It no longer forces string literal arguments, and instead utilizes template strings to handle arbitrary expressions or identifiers.
1c3c46d
to
8413ed3
Compare
packages/ts-transformers/src/internal/decorators/query-assigned-elements.ts
Show resolved
Hide resolved
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.
💯
packages/reactive-element/src/decorators/query-assigned-elements.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/decorators/query-assigned-elements.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/decorators/query-assigned-elements.ts
Outdated
Show resolved
Hide resolved
4255c96
to
ad439fc
Compare
packages/reactive-element/src/decorators/query-assigned-elements.ts
Outdated
Show resolved
Hide resolved
packages/reactive-element/src/test/decorators/queryAssignedElements_test.ts
Show resolved
Hide resolved
Some documentation updates and a missed optional chaining.
ad439fc
to
b3dae4b
Compare
Fixes: #2292
Adds
queryAssignedElements
decorator and tests (that similarly match thequeryAssignedNodes
tests).This change proposes a new options bag API which lets us avoid needing to use and empty string if targeting an unnamed slot.
Note that there is temporarily an asymmetry between this decorator and
queryAssignedNodes
which will be addressed with #2332.How
queryAssignedNodes
tests. In fact the fixture is almost identical.query-assigned-nodes
references in the codebase.Testing
Change is tested with unit tests, as well as transformer tests.