fix(runtime-core): Avoid mutating original options object in createApp (#4840)
fix #4398
This commit is contained in:
@@ -91,9 +91,9 @@ describe('resolveAssets', () => {
|
||||
const root = nodeOps.createElement('div')
|
||||
app.mount(root)
|
||||
|
||||
expect(component1!).toBe(Root) // explicit self name reference
|
||||
expect(component1!).toMatchObject(Root) // explicit self name reference
|
||||
expect(component2!).toBe(Foo) // successful resolve take higher priority
|
||||
expect(component3!).toBe(Root) // fallback when resolve fails
|
||||
expect(component3!).toMatchObject(Root) // fallback when resolve fails
|
||||
})
|
||||
|
||||
describe('warning', () => {
|
||||
|
||||
@@ -179,6 +179,11 @@ export function createAppAPI<HostElement>(
|
||||
hydrate?: RootHydrateFunction
|
||||
): CreateAppFunction<HostElement> {
|
||||
return function createApp(rootComponent, rootProps = null) {
|
||||
|
||||
if (!isFunction(rootComponent)) {
|
||||
rootComponent = { ...rootComponent }
|
||||
}
|
||||
|
||||
if (rootProps != null && !isObject(rootProps)) {
|
||||
__DEV__ && warn(`root props passed to app.mount() must be an object.`)
|
||||
rootProps = null
|
||||
|
||||
Reference in New Issue
Block a user