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

Function executeSignalOperation

packages/qwik/src/core/render/dom/signals.ts:15–104  ·  view source on GitHub ↗
(rCtx: RenderContext, operation: SubscriberSignal)

Source from the content-addressed store, hash-verified

13import { isQwikElement } from '../../util/element';
14
15export const executeSignalOperation = (rCtx: RenderContext, operation: SubscriberSignal) => {
16 try {
17 const type = operation[0];
18 const staticCtx = rCtx.$static$;
19 switch (type) {
20 case 1:
21 case 2: {
22 let elm;
23 let hostElm;
24 if (type === 1) {
25 elm = operation[1];
26 hostElm = operation[3];
27 } else {
28 elm = operation[3];
29 hostElm = operation[1];
30 }
31 // assertTrue(elm.isConnected, 'element must be connected to the dom');
32 // assertTrue(hostElm.isConnected, 'host element must be connected to the dom');
33 const elCtx = tryGetContext(elm);
34 if (elCtx == null) {
35 return;
36 }
37 const prop = operation[4];
38 const isSVG = elm.namespaceURI === SVG_NS;
39 staticCtx.$containerState$.$subsManager$.$clearSignal$(operation);
40 let value = trackSignal(operation[2], operation.slice(0, -1) as any) as any;
41 if (prop === 'class') {
42 value = serializeClassWithHost(value, tryGetContext(hostElm));
43 } else if (prop === 'style') {
44 value = stringifyStyle(value);
45 }
46 const vdom = getVdom(elCtx);
47 if (prop in vdom.$props$ && vdom.$props$[prop] === value) {
48 return;
49 }
50 vdom.$props$[prop] = value;
51 return smartSetProperty(staticCtx, elm, prop, value, isSVG);
52 }
53 case 3:
54 case 4: {
55 const elm = operation[3];
56 if (!staticCtx.$visited$.includes(elm)) {
57 // assertTrue(elm.isConnected, 'text node must be connected to the dom');
58 staticCtx.$containerState$.$subsManager$.$clearSignal$(operation);
59 // MISKO: I believe no `invocationContext` is OK because the JSX in signal
60 // has already been converted to JSX and there is nothing to execute there.
61 const invocationContext = undefined;
62 let signalValue = trackSignal(operation[2], operation.slice(0, -1) as any);
63 const subscription = getLastSubscription()!;
64
65 if (Array.isArray(signalValue)) {
66 signalValue = new JSXNodeImpl<typeof Virtual>(Virtual, {}, null, signalValue, 0, null);
67 }
68 let newVnode = processData(signalValue, invocationContext) as
69 | ProcessedJSXNode
70 | undefined;
71 if (isPromise(newVnode)) {
72 logError('Rendering promises in JSX signals is not supported');

Callers 1

renderMarkedFunction · 0.90

Calls 15

tryGetContextFunction · 0.90
trackSignalFunction · 0.90
serializeClassWithHostFunction · 0.90
stringifyStyleFunction · 0.90
getVdomFunction · 0.90
smartSetPropertyFunction · 0.90
getLastSubscriptionFunction · 0.90
processDataFunction · 0.90
isPromiseFunction · 0.90
logErrorFunction · 0.90
getVnodeFromElFunction · 0.90
getContextFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…