Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework children diffing to run in multiple phases #4162

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jsx-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ function createVNode(type, props, key, isStaticChildren, __source, __self) {
_hydrating: null,
constructor: undefined,
_original: --vnodeId,
_flags: 0,
_index: -1,
__source,
__self
};
Expand Down
4 changes: 4 additions & 0 deletions mangle.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"$_dom": "__e",
"$_hydrating": "__h",
"$_component": "__c",
"$_flags": "__u",
"$_insert": "__r",
"$_matched": "__s",
"$_index": "__i",
"$__html": "__html",
"$_parent": "__",
"$_pendingError": "__E",
Expand Down
2 changes: 1 addition & 1 deletion src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function getDomSibling(vnode, childIndex) {
// Since updateParentDomPointers keeps _dom pointer correct,
// we can rely on _dom to tell us if this subtree contains a
// rendered DOM node, and what the first rendered DOM node is
return sibling._nextDom || sibling._dom;
return sibling._dom;
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/** Indicates that this node needs to be inserted while patching children */
export const INSERT_VNODE = 1 << 16;
export const MATCHED = 1 << 17;

/** Reset all mode flags */
export const RESET_MODE = ~(INSERT_VNODE | MATCHED);

export const EMPTY_OBJ = {};
export const EMPTY_VNODE = /** @type {import('./internal').VNode} */ (
EMPTY_OBJ
);
Comment on lines +9 to +11
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably unnecessary - will undo to reduce size later. Did this temporarily to make TypeScript happy in my editor.

export const EMPTY_ARR = [];
export const IS_NON_DIMENSIONAL =
/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
6 changes: 5 additions & 1 deletion src/create-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ export function createVNode(type, props, key, ref, original) {
_component: null,
_hydrating: null,
constructor: undefined,
_original: original == null ? ++vnodeId : original
_original: original == null ? ++vnodeId : original,
// TODO: Consolidate new VNode fields and add mangle.json entries for new
// ones that stay
_flags: 0,
_index: -1
};

// Only invoke the vnode hook if this was *not* a direct copy:
Expand Down
Loading