Skip to content

Commit

Permalink
docs(runtime): add JSDoc to and rename callNodeRefs (#4251)
Browse files Browse the repository at this point in the history
This is a really small change that was overlooked when a bunch of JSDoc
was added to this file in #3931. The `callNodeRefs` function is renamed
to `nullifyVNodeRefs` and a JSDoc comment is added as well.
  • Loading branch information
alicewriteswrongs committed Apr 11, 2023
1 parent 63d655a commit 1cd079c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/runtime/vdom/vdom-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ const removeVnodes = (vnodes: d.VNode[], startIdx: number, endIdx: number, vnode
for (; startIdx <= endIdx; ++startIdx) {
if ((vnode = vnodes[startIdx])) {
elm = vnode.$elm$;
callNodeRefs(vnode);
nullifyVNodeRefs(vnode);

if (BUILD.slotRelocation) {
// we're removing this element
Expand Down Expand Up @@ -778,10 +778,17 @@ const isNodeLocatedInSlot = (nodeToRelocate: d.RenderNode, slotNameAttr: string)
return slotNameAttr === '';
};

export const callNodeRefs = (vNode: d.VNode) => {
/**
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
* calling them with `null`. This signals that the DOM element corresponding to
* the VDom node has been removed from the DOM.
*
* @param vNode a virtual DOM node
*/
export const nullifyVNodeRefs = (vNode: d.VNode) => {
if (BUILD.vdomRef) {
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
vNode.$children$ && vNode.$children$.map(callNodeRefs);
vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
}
};

Expand Down

0 comments on commit 1cd079c

Please sign in to comment.