-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
refactor(runtime-core): check props
rather than propsOptions[0]
#13514
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe update simplifies property access logic in the component public instance proxy by removing an intermediate variable and directly checking for property existence in the component's props object. The core behavior and structure of property resolution remain unchanged, with no modifications to public or exported APIs. Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code Graph Analysis (1)packages/runtime-core/src/componentPublicInstance.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🔇 Additional comments (2)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
Size ReportBundles
Usages
|
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
This is minor refactoring of the logic for handling props in
PublicInstanceProxyHandlers.get
andPublicInstanceProxyHandlers.has
, switching it from checkingpropsOptions[0]
to checkingprops
. The new version is simpler and leads to a smaller build.In Vue 3.0, props could be missing from the
props
object. Props were only included if they were passed in by the parent or had a default value. The logic inPublicInstanceProxyHandlers
couldn't rely on checkingprops
, so it checkedpropsOptions[0]
instead.That changed in 3.1.0. See #3288 for more details, but
props
now contains all the props.Some other notes about what I changed and why...
set
hasn't been changed as that was already usingprops
.EMPTY_OBJ
(as used for other sources of properties, e.g.data
), butprops
won't be anEMPTY_OBJ
by the time this code runs, even for components that don't declare any props.propsOptions
is populated beforeprops
, so there is potentially a timing issue introduced by this change. However, in practice, the only user-facing 'hook' that runs between the population of those two objects is thedefault
function for a prop. Thedefault
function doesn't have access to the relevant proxy, so it could only encounter a problem if it calledgetCurrentInstance().proxy
(which it shouldn't be doing anyway) and then did some very strange things with it. I don't think this is a realistic case.ctx
(seeexposePropsOnRenderContext
in the same file). Even if the logic for props is wrong it still 'works' because they're accessed viactx
instead. If the logic were wrong it would likely only fail in a production build.Summary by CodeRabbit