forked from angular/angular
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): support deferred triggers with implicit triggers (angular…
…#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
- Loading branch information
1 parent
83ab8fb
commit a05ec7c
Showing
12 changed files
with
506 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...i/test/compliance/test_cases/r3_view_compiler_deferred/deferred_with_implicit_triggers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
@defer (on hover, interaction, viewport; prefetch on hover, interaction, viewport) { | ||
{{message}} | ||
} @placeholder { | ||
<button>Click me</button> | ||
} | ||
`, | ||
}) | ||
export class MyApp { | ||
message = 'hello'; | ||
} |
20 changes: 20 additions & 0 deletions
20
...mpliance/test_cases/r3_view_compiler_deferred/deferred_with_implicit_triggers_template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
function MyApp_DeferPlaceholder_1_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵelementStart(0, "button"); | ||
$r3$.ɵɵtext(1, "Click me"); | ||
$r3$.ɵɵelementEnd(); | ||
} | ||
} | ||
… | ||
function MyApp_Template(rf, ctx) { | ||
if (rf & 1) { | ||
$r3$.ɵɵtemplate(0, MyApp_Defer_0_Template, 1, 1)(1, MyApp_DeferPlaceholder_1_Template, 2, 0); | ||
$r3$.ɵɵdefer(2, 0, null, null, 1); | ||
$r3$.ɵɵdeferOnHover(0, -1); | ||
$r3$.ɵɵdeferOnInteraction(0, -1); | ||
$r3$.ɵɵdeferOnViewport(0, -1); | ||
$r3$.ɵɵdeferPrefetchOnHover(0, -1); | ||
$r3$.ɵɵdeferPrefetchOnInteraction(0, -1); | ||
$r3$.ɵɵdeferPrefetchOnViewport(0, -1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.