Skip to content

Commit 3b509a7

Browse files
committed
fix: CProgressBar fix props inheritance.
1 parent b347731 commit 3b509a7

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/components/Progress/CProgressBar.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,23 @@ export default {
1818
props,
1919
inject: {
2020
progress: {
21-
default: null
21+
default: undefined
2222
}
2323
},
2424
computed: {
25+
directlyDeclaredProps () {
26+
return Object.keys(this.$options.propsData)
27+
},
28+
injectedProps () {
29+
return this.progress && this.progress.props ? this.progress.props : {}
30+
},
2531
props () {
26-
return Object.keys(props).reduce((props, key) => {
27-
const propUndefined = !Object.keys(this.$options.propsData).includes(key)
28-
const propInheritedFromProgress = propUndefined && this.progress.props[key]
29-
props[key] = propInheritedFromProgress ? this.progress.props[key] : this[key]
30-
return props
32+
return Object.keys(props).reduce((computedProps, key) => {
33+
const propIsDirectlyDeclared = this.directlyDeclaredProps.includes(key)
34+
const parentPropExists = this.injectedProps[key] !== undefined
35+
const propIsInherited = parentPropExists && !propIsDirectlyDeclared
36+
computedProps[key] = propIsInherited ? this.injectedProps[key] : this[key]
37+
return computedProps
3138
}, {})
3239
},
3340
progressBarClasses () {

0 commit comments

Comments
 (0)