Skip to content

Commit

Permalink
fix(core): adjust element insert position #WIK-4399
Browse files Browse the repository at this point in the history
  • Loading branch information
王焕 committed Jul 16, 2021
1 parent 6c527a2 commit 39f3969
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/src/view/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ export abstract class ViewContainer<T extends ViewContainerItem> implements Afte
if (record.currentIndex === 0 && firstChildComponent) {
const fragment = document.createDocumentFragment();
fragment.append(...record.item.rootNodes);
const firstChildNode = value._results.find(item => Array.from(parentElement.childNodes).indexOf(item.rootNodes[0]) > -1);
// compatibility: rootNode is removed in the test environment
if (firstChildComponent.rootNodes[0] && firstChildComponent.rootNodes[0].parentElement) {
parentElement.insertBefore(fragment, firstChildComponent.rootNodes[0]);
if (firstChildNode) {
parentElement.insertBefore(fragment, firstChildNode.rootNodes[0]);
} else {
parentElement.appendChild(fragment);
}
Expand Down

0 comments on commit 39f3969

Please sign in to comment.