-
Notifications
You must be signed in to change notification settings - Fork 258
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: shallow config issue #607
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { GlobalMountOptions } from './types' | ||
import { AppConfig } from 'vue' | ||
import { config } from './config' | ||
|
||
function mergeStubs(target: Record<string, any>, source: GlobalMountOptions) { | ||
if (source.stubs) { | ||
|
@@ -14,14 +15,18 @@ function mergeStubs(target: Record<string, any>, source: GlobalMountOptions) { | |
} | ||
|
||
export function mergeGlobalProperties( | ||
configGlobal: GlobalMountOptions = {}, | ||
mountGlobal: GlobalMountOptions = {} | ||
): Required<GlobalMountOptions> { | ||
const stubs: Record<string, any> = {} | ||
|
||
const configGlobal: GlobalMountOptions = config?.global ?? {} | ||
mergeStubs(stubs, configGlobal) | ||
mergeStubs(stubs, mountGlobal) | ||
|
||
const renderStubDefaultSlot = | ||
mountGlobal.renderStubDefaultSlot ?? | ||
config?.renderStubDefaultSlot ?? | ||
configGlobal?.renderStubDefaultSlot | ||
|
||
return { | ||
mixins: [...(configGlobal.mixins || []), ...(mountGlobal.mixins || [])], | ||
plugins: [...(configGlobal.plugins || []), ...(mountGlobal.plugins || [])], | ||
|
@@ -31,9 +36,7 @@ export function mergeGlobalProperties( | |
mocks: { ...configGlobal.mocks, ...mountGlobal.mocks }, | ||
config: { ...configGlobal.config, ...mountGlobal.config }, | ||
directives: { ...configGlobal.directives, ...mountGlobal.directives }, | ||
renderStubDefaultSlot: !!(mountGlobal.renderStubDefaultSlot !== undefined | ||
? mountGlobal.renderStubDefaultSlot | ||
: configGlobal.renderStubDefaultSlot) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This library has three points where we can write renderStubDefaultSlot option.
The last one, I wasn't able to find in document, but it exists in GlobalConfigOptions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or if it's for internal, I'll fix my code 🙇🏻 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes sense, nice job figuring this out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot !! |
||
renderStubDefaultSlot | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In mount.ts, mergedConfig is used like this.
So, I unified using mergetConfig.