Skip to content

Commit

Permalink
align mount and patch component closer
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Sep 2, 2022
1 parent b35adfa commit 3c5b881
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/diff/mount.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ export function mount(internal, newVNode, parentDom, startDom) {

let prevContext = rendererState._context;

nextDomSibling = mountComponent(internal, parentDom, startDom);
const renderResult = mountComponent(internal, startDom);
if (renderResult === startDom) {
nextDomSibling = startDom;
} else {
nextDomSibling = mountChildren(
internal,
renderResult,
parentDom,
startDom
);
}

if (internal._commitCallbacks.length) {
rendererState._commitQueue.push(internal);
Expand Down Expand Up @@ -294,7 +304,7 @@ export function mountChildren(internal, children, parentDom, startDom) {
* @param {import('../internal').PreactNode} startDom the preceding node
* @returns {import('../internal').PreactNode} the component's children
*/
function mountComponent(internal, parentDom, startDom) {
function mountComponent(internal, startDom) {
/** @type {import('../internal').Component} */
let c;
let type = /** @type {import('../internal').ComponentType} */ (internal.type);
Expand Down Expand Up @@ -406,5 +416,5 @@ function mountComponent(internal, parentDom, startDom) {
renderResult = [renderResult];
}

return mountChildren(internal, renderResult, parentDom, startDom);
return renderResult;
}

0 comments on commit 3c5b881

Please sign in to comment.