Skip to content

fix(runtime-core): enable config options in beforeCreate and setup #2839

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

Closed
Closed
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
5 changes: 2 additions & 3 deletions packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ export function applyOptions(
deferredProvide: (Data | Function)[] = [],
asMixin: boolean = false
) {
const publicThis = instance.proxy!
const {
// composition
mixins,
Expand Down Expand Up @@ -506,9 +507,7 @@ export function applyOptions(
errorCaptured,
// public API
expose
} = options

const publicThis = instance.proxy!
} = asMixin ? options : publicThis.$options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $options is a merged options, and the merge strategy is decided by the users, this means:

  1. Unreliable
    Users can return any value by customizing the merge strategy, we need to check them.
  2. Logic conflict with applyOptions
    Now, applyOptions is called recursively when initializing options, but $options may contain options from mixins/extends, do we still need recursive calls?

I think we need to carefully redesign, but indeed, this PR looks more reasonable, compared to #2792

const ctx = instance.ctx
const globalMixins = instance.appContext.mixins

Expand Down