|
3 | 3 |
|
4 | 4 | import { RenderBatch, ArrayBuilderSegment, RenderTreeEdit, RenderTreeFrame, EditType, FrameType, ArrayValues } from './RenderBatch/RenderBatch';
|
5 | 5 | import { EventDelegator } from './Events/EventDelegator';
|
6 |
| -import { LogicalElement, PermutationListEntry, toLogicalElement, insertLogicalChild, removeLogicalChild, getLogicalParent, getLogicalChild, createAndInsertLogicalContainer, isSvgElement, permuteLogicalChildren, getClosestDomElement, emptyLogicalElement } from './LogicalElements'; |
| 6 | +import { LogicalElement, PermutationListEntry, toLogicalElement, insertLogicalChild, removeLogicalChild, getLogicalParent, getLogicalChild, createAndInsertLogicalContainer, isSvgElement, permuteLogicalChildren, getClosestDomElement, emptyLogicalElement, getLogicalChildrenArray } from './LogicalElements'; |
7 | 7 | import { applyCaptureIdToElement } from './ElementReferenceCapture';
|
8 | 8 | import { attachToEventDelegator as attachNavigationManagerToEventDelegator } from '../Services/NavigationManager';
|
9 | 9 | import { applyAnyDeferredValue, tryApplySpecialProperty } from './DomSpecialPropertyUtil';
|
@@ -41,15 +41,18 @@ export class BrowserRenderer {
|
41 | 41 | throw new Error(`Root component '${componentId}' could not be attached because its target element is already associated with a root component`);
|
42 | 42 | }
|
43 | 43 |
|
| 44 | + // If we want to append content to the end of the element, we create a new logical child container |
| 45 | + // at the end of the element and treat that as the new parent. |
| 46 | + if (appendContent) { |
| 47 | + const indexAfterLastChild = getLogicalChildrenArray(element).length; |
| 48 | + element = createAndInsertLogicalContainer(element, indexAfterLastChild); |
| 49 | + } |
| 50 | + |
44 | 51 | markAsInteractiveRootComponentElement(element, true);
|
45 | 52 | this.attachComponentToElement(componentId, element);
|
46 | 53 | this.rootComponentIds.add(componentId);
|
47 | 54 |
|
48 |
| - // If we want to preserve existing HTML content of the root element, we don't apply the mechanism for |
49 |
| - // clearing existing children. Rendered content will then append rather than replace the existing HTML content. |
50 |
| - if (!appendContent) { |
51 |
| - elementsToClearOnRootComponentRender.add(element); |
52 |
| - } |
| 55 | + elementsToClearOnRootComponentRender.add(element); |
53 | 56 | }
|
54 | 57 |
|
55 | 58 | public updateComponent(batch: RenderBatch, componentId: number, edits: ArrayBuilderSegment<RenderTreeEdit>, referenceFrames: ArrayValues<RenderTreeFrame>): void {
|
|
0 commit comments