fix(ivy): unable to project into multiple slots with default selector (#30561)
With View engine it was possible to declare multiple projection definitions and to programmatically project nodes into the slots. e.g. ```html <ng-content></ng-content> <ng-content></ng-content> ``` Using `ViewContainerRef#createComponent` allowed projecting nodes into one of the projection defs (through index) This no longer works with Ivy as the `projectionDef` instruction only retrieves a list of selectors instead of also retrieving entries for reserved projection slots which appear when using the default selector multiple times (as seen above). In order to fix this issue, the Ivy compiler now passes all projection slots to the `projectionDef` instruction. Meaning that there can be multiple projection slots with the same wildcard selector. This allows multi-slot projection as seen in the example above, and it also allows us to match the multi-slot node projection order from View Engine (to avoid breaking changes). It basically ensures that Ivy fully matches the View Engine behavior except of a very small edge case that has already been discussed in FW-886 (with the conclusion of working as intended). Read more here: https://hackmd.io/s/Sy2kQlgTE PR Close #30561
This commit is contained in:

committed by
Miško Hevery

parent
f4cd3740b2
commit
aca339e864
@ -50,6 +50,16 @@ export type CssSelector = (string | SelectorFlags)[];
|
||||
*/
|
||||
export type CssSelectorList = CssSelector[];
|
||||
|
||||
/**
|
||||
* List of slots for a projection. A slot can be either based on a parsed CSS selector
|
||||
* which will be used to determine nodes which are projected into that slot.
|
||||
*
|
||||
* When set to "*", the slot is reserved and can be used for multi-slot projection
|
||||
* using {@link ViewContainerRef#createComponent}. The last slot that specifies the
|
||||
* wildcard selector will retrieve all projectable nodes which do not match any selector.
|
||||
*/
|
||||
export type ProjectionSlots = (CssSelectorList | '*')[];
|
||||
|
||||
/** Flags used to build up CssSelectors */
|
||||
export const enum SelectorFlags {
|
||||
/** Indicates this is the beginning of a new negative selector */
|
||||
|
Reference in New Issue
Block a user