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

Function legacyBindObjectProps

packages/runtime-core/src/compat/renderHelpers.ts:27–63  ·  view source on GitHub ↗
(
  data: any,
  _tag: string,
  value: any,
  _asProp: boolean,
  isSync?: boolean,
)

Source from the content-addressed store, hash-verified

25}
26
27export function legacyBindObjectProps(
28 data: any,
29 _tag: string,
30 value: any,
31 _asProp: boolean,
32 isSync?: boolean,
33): any {
34 if (value && isObject(value)) {
35 if (isArray(value)) {
36 value = toObject(value)
37 }
38 for (const key in value) {
39 if (isReservedProp(key)) {
40 data[key] = value[key]
41 } else if (key === 'class') {
42 data.class = normalizeClass([data.class, value.class])
43 } else if (key === 'style') {
44 data.style = normalizeClass([data.style, value.style])
45 } else {
46 const attrs = data.attrs || (data.attrs = {})
47 const camelizedKey = camelize(key)
48 const hyphenatedKey = hyphenate(key)
49 if (!(camelizedKey in attrs) && !(hyphenatedKey in attrs)) {
50 attrs[key] = value[key]
51
52 if (isSync) {
53 const on = data.on || (data.on = {})
54 on[`update:${key}`] = function ($event: any) {
55 value[key] = $event
56 }
57 }
58 }
59 }
60 }
61 }
62 return data
63}
64
65export function legacyBindObjectListeners(props: any, listeners: any): Data {
66 return mergeProps(props, toHandlers(listeners))

Callers

nothing calls this directly

Calls 3

isObjectFunction · 0.90
normalizeClassFunction · 0.90
toObjectFunction · 0.85

Tested by

no test coverage detected