( tData: TData, tNode: TNode, stylingKey: TStylingKey, isClassBased: boolean, )
| 365 | * @param isClassBased `true` if `class` (`false` if `style`) |
| 366 | */ |
| 367 | export function wrapInStaticStylingKey( |
| 368 | tData: TData, |
| 369 | tNode: TNode, |
| 370 | stylingKey: TStylingKey, |
| 371 | isClassBased: boolean, |
| 372 | ): TStylingKey { |
| 373 | const hostDirectiveDef = getCurrentDirectiveDef(tData); |
| 374 | let residual = isClassBased ? tNode.residualClasses : tNode.residualStyles; |
| 375 | if (hostDirectiveDef === null) { |
| 376 | // We are in template node. |
| 377 | // If template node already had styling instruction then it has already collected the static |
| 378 | // styling and there is no need to collect them again. We know that we are the first styling |
| 379 | // instruction because the `TNode.*Bindings` points to 0 (nothing has been inserted yet). |
| 380 | const isFirstStylingInstructionInTemplate = |
| 381 | ((isClassBased ? tNode.classBindings : tNode.styleBindings) as any as number) === 0; |
| 382 | if (isFirstStylingInstructionInTemplate) { |
| 383 | // It would be nice to be able to get the statics from `mergeAttrs`, however, at this point |
| 384 | // they are already merged and it would not be possible to figure which property belongs where |
| 385 | // in the priority. |
| 386 | stylingKey = collectStylingFromDirectives(null, tData, tNode, stylingKey, isClassBased); |
| 387 | stylingKey = collectStylingFromTAttrs(stylingKey, tNode.attrs, isClassBased); |
| 388 | // We know that if we have styling binding in template we can't have residual. |
| 389 | residual = null; |
| 390 | } |
| 391 | } else { |
| 392 | // We are in host binding node and there was no binding instruction in template node. |
| 393 | // This means that we need to compute the residual. |
| 394 | const directiveStylingLast = tNode.directiveStylingLast; |
| 395 | const isFirstStylingInstructionInHostBinding = |
| 396 | directiveStylingLast === -1 || tData[directiveStylingLast] !== hostDirectiveDef; |
| 397 | if (isFirstStylingInstructionInHostBinding) { |
| 398 | stylingKey = collectStylingFromDirectives( |
| 399 | hostDirectiveDef, |
| 400 | tData, |
| 401 | tNode, |
| 402 | stylingKey, |
| 403 | isClassBased, |
| 404 | ); |
| 405 | if (residual === null) { |
| 406 | // - If `null` than either: |
| 407 | // - Template styling instruction already ran and it has consumed the static |
| 408 | // styling into its `TStylingKey` and so there is no need to update residual. Instead |
| 409 | // we need to update the `TStylingKey` associated with the first template node |
| 410 | // instruction. OR |
| 411 | // - Some other styling instruction ran and determined that there are no residuals |
| 412 | let templateStylingKey = getTemplateHeadTStylingKey(tData, tNode, isClassBased); |
| 413 | if (templateStylingKey !== undefined && Array.isArray(templateStylingKey)) { |
| 414 | // Only recompute if `templateStylingKey` had static values. (If no static value found |
| 415 | // then there is nothing to do since this operation can only produce less static keys, not |
| 416 | // more.) |
| 417 | templateStylingKey = collectStylingFromDirectives( |
| 418 | null, |
| 419 | tData, |
| 420 | tNode, |
| 421 | templateStylingKey[1] /* unwrap previous statics */, |
| 422 | isClassBased, |
| 423 | ); |
| 424 | templateStylingKey = collectStylingFromTAttrs( |
no test coverage detected
searching dependent graphs…