Skip to content

Commit 8d89d58

Browse files
committed
preserve actual component props
1 parent 69ecdcb commit 8d89d58

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

Diff for: src/core/vdom/create-component.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,14 @@ function extractProps (data: VNodeData, Ctor: Class<Component>): ?Object {
223223
}
224224
const res = {}
225225
const { attrs, props, domProps, staticAttrs } = data
226-
if (!attrs && !props && !domProps && !staticAttrs) {
227-
return res
228-
}
229-
for (const key in propOptions) {
230-
const altKey = hyphenate(key)
231-
checkProp(res, attrs, key, altKey) ||
232-
checkProp(res, props, key, altKey) ||
233-
checkProp(res, domProps, key, altKey) ||
234-
checkProp(res, staticAttrs, key, altKey)
226+
if (attrs || props || domProps || staticAttrs) {
227+
for (const key in propOptions) {
228+
const altKey = hyphenate(key)
229+
checkProp(res, props, key, altKey, true) ||
230+
checkProp(res, attrs, key, altKey) ||
231+
checkProp(res, domProps, key, altKey) ||
232+
checkProp(res, staticAttrs, key, altKey)
233+
}
235234
}
236235
return res
237236
}
@@ -240,16 +239,21 @@ function checkProp (
240239
res: Object,
241240
hash: ?Object,
242241
key: string,
243-
altKey: string
242+
altKey: string,
243+
preserve?: boolean
244244
): boolean {
245245
if (hash) {
246246
if (hasOwn(hash, key)) {
247247
res[key] = hash[key]
248-
delete hash[key]
248+
if (!preserve) {
249+
delete hash[key]
250+
}
249251
return true
250252
} else if (hasOwn(hash, altKey)) {
251253
res[key] = hash[altKey]
252-
delete hash[altKey]
254+
if (!preserve) {
255+
delete hash[altKey]
256+
}
253257
return true
254258
}
255259
}

0 commit comments

Comments
 (0)