MCPcopy
hub / github.com/vuejs/core / defineLegacyVNodeProperties

Function defineLegacyVNodeProperties

packages/runtime-core/src/compat/renderFn.ts:308–350  ·  view source on GitHub ↗
(vnode: VNode)

Source from the content-addressed store, hash-verified

306}
307
308export function defineLegacyVNodeProperties(vnode: VNode): void {
309 /* v8 ignore start */
310 if (
311 isCompatEnabled(
312 DeprecationTypes.RENDER_FUNCTION,
313 currentRenderingInstance,
314 true /* enable for built-ins */,
315 ) &&
316 isCompatEnabled(
317 DeprecationTypes.PRIVATE_APIS,
318 currentRenderingInstance,
319 true /* enable for built-ins */,
320 )
321 ) {
322 const context = currentRenderingInstance
323 const getInstance = () => vnode.component && vnode.component.proxy
324 let componentOptions: any
325 Object.defineProperties(vnode, {
326 tag: { get: () => vnode.type },
327 data: { get: () => vnode.props || {}, set: p => (vnode.props = p) },
328 elm: { get: () => vnode.el },
329 componentInstance: { get: getInstance },
330 child: { get: getInstance },
331 text: { get: () => (isString(vnode.children) ? vnode.children : null) },
332 context: { get: () => context && context.proxy },
333 componentOptions: {
334 get: () => {
335 if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
336 if (componentOptions) {
337 return componentOptions
338 }
339 return (componentOptions = {
340 Ctor: vnode.type,
341 propsData: vnode.props,
342 children: vnode.children,
343 })
344 }
345 },
346 },
347 })
348 }
349 /* v8 ignore stop */
350}

Callers 2

createBaseVNodeFunction · 0.90
cloneVNodeFunction · 0.90

Calls 2

isCompatEnabledFunction · 0.90
isStringFunction · 0.90

Tested by

no test coverage detected