|
6 | 6 | * found in the LICENSE file at https://angular.io/license
|
7 | 7 | */
|
8 | 8 |
|
| 9 | +import {ViewEncapsulation} from '../core'; |
| 10 | + |
9 | 11 | import {attachPatchData} from './context_discovery';
|
10 | 12 | import {callHooks} from './hooks';
|
11 | 13 | import {LContainer, NATIVE, VIEWS, unusedValueExportToPlacateAjd as unused1} from './interfaces/container';
|
| 14 | +import {ComponentDef} from './interfaces/definition'; |
12 | 15 | import {TContainerNode, TElementContainerNode, TElementNode, TNode, TNodeFlags, TNodeType, TProjectionNode, TViewNode, unusedValueExportToPlacateAjd as unused2} from './interfaces/node';
|
13 | 16 | import {unusedValueExportToPlacateAjd as unused3} from './interfaces/projection';
|
14 | 17 | import {ProceduralRenderer3, RComment, RElement, RNode, RText, Renderer3, isProceduralRenderer, unusedValueExportToPlacateAjd as unused4} from './interfaces/renderer';
|
@@ -486,7 +489,7 @@ function executeOnDestroys(view: LView): void {
|
486 | 489 | * `<component><content>delayed due to projection</content></component>`
|
487 | 490 | * - Parent container is disconnected: This can happen when we are inserting a view into
|
488 | 491 | * parent container, which itself is disconnected. For example the parent container is part
|
489 |
| - * of a View which has not be inserted or is mare for projection but has not been inserted |
| 492 | + * of a View which has not be inserted or is made for projection but has not been inserted |
490 | 493 | * into destination.
|
491 | 494 | */
|
492 | 495 | function getRenderParent(tNode: TNode, currentView: LView): RElement|null {
|
@@ -519,15 +522,24 @@ function getRenderParent(tNode: TNode, currentView: LView): RElement|null {
|
519 | 522 | }
|
520 | 523 | } else {
|
521 | 524 | ngDevMode && assertNodeType(parent, TNodeType.Element);
|
522 |
| - // We've got a parent which is an element in the current view. We just need to verify if the |
523 |
| - // parent element is not a component. Component's content nodes are not inserted immediately |
524 |
| - // because they will be projected, and so doing insert at this point would be wasteful. |
525 |
| - // Since the projection would then move it to its final destination. |
526 | 525 | if (parent.flags & TNodeFlags.isComponent) {
|
527 |
| - return null; |
528 |
| - } else { |
529 |
| - return getNativeByTNode(parent, currentView) as RElement; |
| 526 | + const tData = currentView[TVIEW].data; |
| 527 | + const tNode = tData[parent.index] as TNode; |
| 528 | + const encapsulation = (tData[tNode.directiveStart] as ComponentDef<any>).encapsulation; |
| 529 | + |
| 530 | + // We've got a parent which is an element in the current view. We just need to verify if the |
| 531 | + // parent element is not a component. Component's content nodes are not inserted immediately |
| 532 | + // because they will be projected, and so doing insert at this point would be wasteful. |
| 533 | + // Since the projection would then move it to its final destination. Note that we can't |
| 534 | + // make this assumption when using the Shadow DOM, because the native projection placeholders |
| 535 | + // (<content> or <slot>) have to be in place as elements are being inserted. |
| 536 | + if (encapsulation !== ViewEncapsulation.ShadowDom && |
| 537 | + encapsulation !== ViewEncapsulation.Native) { |
| 538 | + return null; |
| 539 | + } |
530 | 540 | }
|
| 541 | + |
| 542 | + return getNativeByTNode(parent, currentView) as RElement; |
531 | 543 | }
|
532 | 544 | }
|
533 | 545 |
|
|
0 commit comments