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

refactor(reactivity): priority check if the object is invalid #10419

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

OnlyWick
Copy link
Contributor

  • If the object is non-extensible from the beginning, return the original object directly, without the need to check the cache first.

  • If the original object has already been proxied and subsequently becomes non-extensible, when attempting to proxy it again, it should return the original object directly.

  • Removed comments and used variable names instead.

Copy link

github-actions bot commented Feb 27, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 90.5 kB (-12 B) 34.4 kB (+2 B) 31 kB (+2 B)
vue.global.prod.js 148 kB (-12 B) 53.7 kB (+3 B) 47.9 kB (+20 B)

Usages

Name Size Gzip Brotli
createApp 50.7 kB 19.8 kB (+8 B) 18.1 kB (+14 B)
createSSRApp 54.1 kB 21.1 kB (+10 B) 19.3 kB (+14 B)
defineCustomElement 53 kB 20.6 kB (+9 B) 18.8 kB (+55 B)
overall 64.4 kB 24.8 kB (+10 B) 22.5 kB (-3 B)

target[ReactiveFlags.RAW] &&
!(isReadonly && target[ReactiveFlags.IS_REACTIVE])
) {
const targetType = getTargetType(target)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@OnlyWick OnlyWick Feb 28, 2024

Choose a reason for hiding this comment

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

Yeah, Object.freeze() is rarely used. I believe that instead of checking the cache first, we should ensure that the object is not INVALID before considering the subsequent actions.

https://deploy-preview-10419--vue-sfc-playground.netlify.app/#eNp9UkFOwzAQ/MrKl4JUEhU4VWklQD3AgSLg6EvqbFOXxLbsTVoR5e9sUqUtAvXmnZkdzVjbiAfnorpCMRVJUF47goBUubk0unTWEzTgMVWkaxzDLiW1gRbW3pYw4rWRNNIoawJBGXKYQZNOm9UURpNR20oTx+AqAm1ApWqDZ9Jb1g6+VzxfS7NcbVFRtPaI3wPGBpkFYwl4XX39trGrgL7G7K9VEh+6cAseCEtXpIQ8AUCymcyb5rTctknMUMcl2nRx65vSZljMpBhEURqtpICYVUl8ZifGggKHWes82gZr+BebzkgKZUunC/RLR5rDSjGFnum4tCjs7qXHyFc4HvC+4j/4Nuw7TIo3j30eKY4cpT5HOtCLj1fc8/tIco2qYPUF8h2DLaou40H2WJmMY5/p+rTP/S1ok3+GxZ7QhKFUF7RTtr1eCr6JpwvVT3Hvovt+T5pWtD+UnNlX

Although this example is peculiar, in case there is a large amount of code within a single SFC, maintained by multiple people, if someone misuses Object.freeze() and another person proxies the original object, an error would be thrown in the now Vue version. However, if the object is INVALID, just return the original object directly, in your case, the error won't occur.

@baiwusanyu-c
Copy link
Member

/ecosystem-ci run

@vue-bot
Copy link

vue-bot commented Feb 29, 2024

📝 Ran ecosystem CI: Open

suite result latest scheduled
language-tools success failure
nuxt success success
pinia success success
quasar failure success
radix-vue success success
router success success
test-utils success success
vant success success
vite-plugin-vue success success
vitepress success success
vue-i18n success success
vue-macros success success
vuetify success success
vueuse success success
vue-simple-compiler success success

@sodatea sodatea added the 🧹 p1-chore Priority 1: this doesn't change code behavior. label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧹 p1-chore Priority 1: this doesn't change code behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants