( node: TemplateChildNode, options: TransformOptions, parentContext: TransformContext, )
| 335 | } |
| 336 | |
| 337 | function subTransform( |
| 338 | node: TemplateChildNode, |
| 339 | options: TransformOptions, |
| 340 | parentContext: TransformContext, |
| 341 | ) { |
| 342 | const childRoot = createRoot([node]) |
| 343 | const childContext = createTransformContext(childRoot, options) |
| 344 | // this sub transform is for vnode fallback branch so it should be handled |
| 345 | // like normal render functions |
| 346 | childContext.ssr = false |
| 347 | // inherit parent scope analysis state |
| 348 | childContext.scopes = { ...parentContext.scopes } |
| 349 | childContext.identifiers = { ...parentContext.identifiers } |
| 350 | childContext.imports = parentContext.imports |
| 351 | // traverse |
| 352 | traverseNode(childRoot, childContext) |
| 353 | // merge helpers/components/directives into parent context |
| 354 | ;(['helpers', 'components', 'directives'] as const).forEach(key => { |
| 355 | childContext[key].forEach((value: any, helperKey: any) => { |
| 356 | if (key === 'helpers') { |
| 357 | const parentCount = parentContext.helpers.get(helperKey) |
| 358 | if (parentCount === undefined) { |
| 359 | parentContext.helpers.set(helperKey, value) |
| 360 | } else { |
| 361 | parentContext.helpers.set(helperKey, value + parentCount) |
| 362 | } |
| 363 | } else { |
| 364 | ;(parentContext[key] as any).add(value) |
| 365 | } |
| 366 | }) |
| 367 | }) |
| 368 | // imports/hoists are not merged because: |
| 369 | // - imports are only used for asset urls and should be consistent between |
| 370 | // node/client branches |
| 371 | // - hoists are not enabled for the client branch here |
| 372 | } |
| 373 | |
| 374 | function clone(v: any): any { |
| 375 | if (isArray(v)) { |
no test coverage detected