vuejs / core

🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
https://vuejs.org/
MIT License
45.6k stars 8k forks source link

feat: use encapsulated api #11220

Open OnlyWick opened 1 week ago

OnlyWick commented 1 week ago

This can reduce tens of bytes.

ferferga commented 1 week ago

There are other typeof instances across the codebase, why not do this in all of them?

OnlyWick commented 1 week ago

There are other typeof instances across the codebase, why not do this in all of them?

Yep, 'typeof xxx === 'function'' can be replaced with the isFunction function. typeof xxx === 'undefined' can also be encapsulated into an API.

skirtles-code commented 1 week ago

This seems similar to #8505, which wasn't merged due to https://github.com/vuejs/core/pull/8505#issuecomment-2139233216.

OnlyWick commented 1 week ago

This seems similar to #8505, which wasn't merged due to #8505 (comment).

I indeed didn't expect there to be a similar PR. Strangely, in the compiler, methods like isString and isSymbol have already been used. I believe all these should be replaced with encapsulated APIs to ensure consistency in code style.