(rCtx: RenderContext, operation: SubscriberSignal)
| 13 | import { isQwikElement } from '../../util/element'; |
| 14 | |
| 15 | export 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'); |
no test coverage detected
searching dependent graphs…