Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): make component custom property take precedence #1983

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/runtime-core/__tests__/apiCreateApp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,27 @@ describe('api: createApp', () => {
expect(merged!).toBe('global,extends,mixin,local')
})

test('config without optionMergeStrategies', () => {
let merged: string
const App = defineComponent({
render() {},
mixins: [{ foo: 'mixin' }],
extends: { foo: 'extends' },
foo: 'local',
beforeCreate() {
merged = this.$options.foo
}
})

const app = createApp(App)
app.mixin({
foo: 'global'
})

app.mount(nodeOps.createElement('div'))
expect(merged!).toBe('local')
})

test('config.globalProperties', () => {
const app = createApp({
render() {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ function mergeOptions(to: any, from: any, instance: ComponentInternalInstance) {
for (const key in from) {
if (strats && hasOwn(strats, key)) {
to[key] = strats[key](to[key], from[key], instance.proxy, key)
} else if (!hasOwn(to, key)) {
} else {
to[key] = from[key]
}
}
Expand Down