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
Support for implicit deferred triggers and better diagnostics for triggers #51922
Conversation
If a trigger element can't be accessed from the defer block, we don't generate any instructions for it. These changes add a diagnostic that will surface the error to users.
Adds support for defining `viewport`, `interaction` and `hover` triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the `@placeholder` block. Triggers with no parameters have the following restrictions: 1. They have to be placed on an `@defer` block that has an `@placeholder`. 2. The `@placeholder` can only have one root node. 3. The root placeholder node has to be an element.
0f7d74f
to
7378f3d
Compare
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, but curious about the requirement of a single root node.
reviewed-for: fw-core, public-api
// If the trigger doesn't have a reference, it is inferred as the root element node of the | ||
// placeholder, if it only has one root node. Otherwise it's ambiguous so we don't | ||
// attempt to resolve further. | ||
return children !== null && children.length === 1 && children[0] instanceof Element ? |
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.
Why not just apply the trigger to every root node rather than require one?
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.
What we'd talked about was that if there are multiple root nodes, it could lead to some weird situations like a closing icon positioned at the top of the container causing the entire thing to load. Binding to each root node can also be a problem for the interaction
and hover
triggers, because there could be text nodes in-between that won't fire any events.
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.
reviewed-for: public-api
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 PR was merged into the repository by commit e2e3d69. |
Adds support for defining `viewport`, `interaction` and `hover` triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the `@placeholder` block. Triggers with no parameters have the following restrictions: 1. They have to be placed on an `@defer` block that has an `@placeholder`. 2. The `@placeholder` can only have one root node. 3. The root placeholder node has to be an element. PR Close #51922
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…lar#51922) If a trigger element can't be accessed from the defer block, we don't generate any instructions for it. These changes add a diagnostic that will surface the error to users. PR Close angular#51922
…#51922) Adds support for defining `viewport`, `interaction` and `hover` triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the `@placeholder` block. Triggers with no parameters have the following restrictions: 1. They have to be placed on an `@defer` block that has an `@placeholder`. 2. The `@placeholder` can only have one root node. 3. The root placeholder node has to be an element. PR Close angular#51922
Adds support for
viewport
,hover
andinteraction
deferred triggers with an implicit element reference, as well as a diagnostic for the case where the deferred block can't resolve its trigger element. Split up into the following commits:fix(compiler): add diagnostic for inaccessible deferred trigger
If a trigger element can't be accessed from the defer block, we don't generate any instructions for it. These changes add a diagnostic that will surface the error to users.
feat(core): support deferred triggers with implicit triggers
Adds support for defining
viewport
,interaction
andhover
triggers with no parameters. If the framework encounters such a case, it resolves the trigger to the root element of the@placeholder
block. Triggers with no parameters have the following restrictions:@defer
block that has an@placeholder
.@placeholder
can only have one root node.