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

fix: Ref transform being applied to variables named hasOwnProperty. #4515

Closed
wants to merge 1 commit into from

Conversation

aphex
Copy link

@aphex aphex commented Sep 3, 2021

Given the variable var hasOwnProperty = Object.prototype.hasOwnProperty running through the transformer will result in

https://github.com/vuejs/vue-next/blob/master/packages/ref-transform/src/refTransform.ts#L313
id.name being hasOwnProperty which will return truthy for all objects. So instead we check for strict equality. We will only get properties flagged true in the scope passing through to be transformed.

This problem is blowing up all applications when using refTransform: true as @vue/shared is doing this exact thing here
https://github.com/vuejs/vue-next/blob/master/packages/shared/src/index.ts#L54

When running vite in dev mode the line below is being transformed to

var hasOwn = (val, key) => hasOwnProperty.value.call(val, key);

This small update will fix that.

@aphex aphex changed the title Fix to ref transform being applied to variables named hasOwnProperty. fix: Ref transform being applied to variables named hasOwnProperty. Sep 3, 2021
@edison1105
Copy link
Member

@aphex is this a duplicate of #4503 ?
/cc @ygj6

@ygj6
Copy link
Member

ygj6 commented Sep 4, 2021

@aphex这是#4503的副本吗?
/cc @ygj6

yes:stuck_out_tongue:

@aphex
Copy link
Author

aphex commented Sep 5, 2021

Yup, I will close mine as theirs looks good to me and has a test 😍

@aphex aphex closed this Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants