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(compiler-core): avoid using component name as parameter name #11731

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

Conversation

linzhe141
Copy link
Contributor

@linzhe141 linzhe141 commented Aug 28, 2024

@linzhe141 linzhe141 marked this pull request as draft August 28, 2024 09:08
Copy link

github-actions bot commented Aug 28, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB 37.7 kB 33.9 kB
vue.global.prod.js 159 kB 57.5 kB (+4 B) 51.1 kB (+6 B)

Usages

Name Size Gzip Brotli
createApp 55.1 kB 21.2 kB 19.3 kB
createSSRApp 59.1 kB 22.9 kB 20.8 kB
defineCustomElement 59.8 kB 22.7 kB 20.7 kB
overall 68.8 kB 26.3 kB 23.9 kB

Copy link

pkg-pr-new bot commented Aug 28, 2024

commit: bbea42f

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@11731

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@11731

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@11731

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@11731

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@11731

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@11731

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@11731

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@11731

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@11731

vue

pnpm add https://pkg.pr.new/vue@11731

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@11731

Open in Stackblitz

@edison1105
Copy link
Member

the cause is here

checkType(BindingTypes.LITERAL_CONST)
if (fromConst) {
return context.inline
? // in inline mode, const setup bindings (e.g. imports) can be used as-is
fromConst
: `$setup[${JSON.stringify(fromConst)}]`
}

@linzhe141
Copy link
Contributor Author

if (
currentTag &&
identifiers &&
identifiers.some(i => i === currentTag)
Copy link
Member

Choose a reason for hiding this comment

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

This check is not correct. Consider the following scenario:

  <div v-for="Comp of list">
    <Comp>{{Comp}}</Comp>
  </div>

Playground

@linzhe141 linzhe141 marked this pull request as ready for review August 28, 2024 12:28
@linzhe141 linzhe141 changed the title fix(compiler-core): renderExp should not use parameters fix(compiler-core): the parameter name cannot be the same as the current component name using v-for Aug 28, 2024
@edison1105
Copy link
Member

the cause is here
741d8a0/packages/compiler-core/src/transforms/transformElement.ts#L345-In

this case, throwing an error might be more reasonable?

I think so

@linzhe141 linzhe141 changed the title fix(compiler-core): the parameter name cannot be the same as the current component name using v-for fix(compiler-core): the value in binding metadata cannot be used as a parameter using v-for Aug 28, 2024
@linzhe141 linzhe141 marked this pull request as draft August 29, 2024 02:07
@linzhe141 linzhe141 changed the title fix(compiler-core): the value in binding metadata cannot be used as a parameter using v-for fix(compiler-core): the parameter name cannot be the same as the component name Aug 29, 2024
@linzhe141 linzhe141 marked this pull request as ready for review August 29, 2024 03:21
@linzhe141 linzhe141 changed the title fix(compiler-core): the parameter name cannot be the same as the component name fix(compiler-core): the v-for parameter name cannot be the same as the component name Aug 29, 2024
@edison1105
Copy link
Member

Consider this scenario

@linzhe141 linzhe141 marked this pull request as draft August 29, 2024 08:29
@linzhe141
Copy link
Contributor Author

linzhe141 commented Aug 29, 2024

Consider this scenario

Yeah, there are some other scenarios besides v-for that I didn't consider.

@linzhe141 linzhe141 changed the title fix(compiler-core): the v-for parameter name cannot be the same as the component name fix(compiler-core): the parameter name cannot be the same as the component name Aug 29, 2024
@linzhe141 linzhe141 marked this pull request as ready for review August 29, 2024 09:48
@linzhe141 linzhe141 changed the title fix(compiler-core): the parameter name cannot be the same as the component name fix(compiler-core): avoid using component name as parameter name Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants