Fix <component> tag helpers being siblings. Fixes #17851 (#17910)

This commit is contained in:
Steve Sanderson 2020-01-06 16:33:45 +00:00 committed by GitHub
parent 995781c761
commit ba246719f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -54,13 +54,14 @@ export function toLogicalRootCommentElement(start: Comment, end: Comment): Logic
const parentLogicalElement = toLogicalElement(parent, /* allow existing contents */ true);
const children = getLogicalChildrenArray(parentLogicalElement);
Array.from(parent.childNodes).forEach(n => children.push(n as unknown as LogicalElement));
start[logicalParentPropname] = parentLogicalElement;
// We might not have an end comment in the case of non-prerendered components.
if (end) {
start[logicalEndSiblingPropname] = end;
toLogicalElement(end, /* allowExistingcontents */ true);
toLogicalElement(end);
}
return toLogicalElement(start, /* allowExistingContents */ true);
return toLogicalElement(start);
}
export function toLogicalElement(element: Node, allowExistingContents?: boolean): LogicalElement {
@ -71,7 +72,10 @@ export function toLogicalElement(element: Node, allowExistingContents?: boolean)
throw new Error('New logical elements must start empty, or allowExistingContents must be true');
}
element[logicalChildrenPropname] = [];
if (!(logicalChildrenPropname in element)) { // If it's already a logical element, leave it alone
element[logicalChildrenPropname] = [];
}
return element as unknown as LogicalElement;
}