MCPcopy
hub / github.com/QwikDev/qwik / diffVnode

Function diffVnode

packages/qwik/src/core/render/dom/visitor.ts:371–509  ·  view source on GitHub ↗
(
  rCtx: RenderContext,
  oldVnode: ProcessedJSXNode,
  newVnode: ProcessedJSXNode,
  flags: number
)

Source from the content-addressed store, hash-verified

369};
370
371export const diffVnode = (
372 rCtx: RenderContext,
373 oldVnode: ProcessedJSXNode,
374 newVnode: ProcessedJSXNode,
375 flags: number
376): ValueOrPromise<void> => {
377 assertEqual(oldVnode.$type$, newVnode.$type$, 'old and new vnodes type must be the same');
378 assertEqual(oldVnode.$key$, newVnode.$key$, 'old and new vnodes key must be the same');
379 assertEqual(oldVnode.$id$, newVnode.$id$, 'old and new vnodes key must be the same');
380 const elm = oldVnode.$elm$;
381 const tag = newVnode.$type$;
382 const staticCtx = rCtx.$static$;
383 const containerState = staticCtx.$containerState$;
384 const currentComponent = rCtx.$cmpCtx$;
385 assertDefined(elm, 'while patching element must be defined');
386 assertDefined(currentComponent, 'while patching current component must be defined');
387
388 newVnode.$elm$ = elm;
389
390 // Render text nodes
391 if (tag === '#text') {
392 staticCtx.$visited$.push(elm);
393 const signal = newVnode.$signal$;
394 if (signal) {
395 newVnode.$text$ = jsxToString(
396 trackSignal(signal, [4, currentComponent.$element$, signal, elm as Text])
397 );
398 }
399 setProperty(staticCtx, elm, 'data', newVnode.$text$);
400 return;
401 } else if (tag === '#signal') {
402 return;
403 }
404 assertQwikElement(elm);
405
406 const props = newVnode.$props$;
407 const vnodeFlags = newVnode.$flags$;
408 const elCtx = getContext(elm, containerState);
409
410 if (tag !== VIRTUAL) {
411 // Track SVG state
412 let isSvg = (flags & IS_SVG) !== 0;
413 if (!isSvg && tag === 'svg') {
414 flags |= IS_SVG;
415 isSvg = true;
416 }
417
418 if (props !== EMPTY_OBJ) {
419 // elCtx.$vdom$ = newVnode;
420 if ((vnodeFlags & static_listeners) === 0) {
421 elCtx.li.length = 0;
422 }
423 const values = oldVnode.$props$;
424 newVnode.$props$ = values;
425 for (const prop in props) {
426 let newValue = props[prop];
427 if (prop === 'ref') {
428 assertElement(elm);

Callers 2

executeSignalOperationFunction · 0.90
diffChildrenFunction · 0.85

Calls 15

assertEqualFunction · 0.90
assertDefinedFunction · 0.90
jsxToStringFunction · 0.90
trackSignalFunction · 0.90
setPropertyFunction · 0.90
assertQwikElementFunction · 0.90
getContextFunction · 0.90
assertElementFunction · 0.90
setRefFunction · 0.90
isOnPropFunction · 0.90
setEventFunction · 0.90
isSignalFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…