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

The production behavior is inconsistent with development behavior #2042

Closed
sionzee opened this issue Sep 3, 2020 · 1 comment
Closed

The production behavior is inconsistent with development behavior #2042

sionzee opened this issue Sep 3, 2020 · 1 comment

Comments

@sionzee
Copy link

sionzee commented Sep 3, 2020

Version

3.0.0-rc.10

Reproduction code

Create test.html file on your desktop and put there this:

<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue@3.0.0-rc.10/dist/vue.global.js"></script>
</head>
<body>
        <div id="app"></div>
	<script>
	
	const InnerComp2 = Vue.defineComponent({
		template: '<div ref="$test2">INSIDE!</div>',
		setup() { return {$test2: Vue.ref(), testValue: "OK"}}
	})
	
	const InnerComp = Vue.defineComponent({
		components: {InnerComp2},
		template: '<InnerComp2 ref="$test1"/>',
		setup() { return {$test1: Vue.ref()}}
	})
	
	const comp = Vue.defineComponent({
		components: {InnerComp},
		template: '<InnerComp ref="myComp"/>',
		setup() {
			const myComp = Vue.ref();
			window.addEventListener("click", () => {
				Vue.nextTick(() => {
					const test2 = myComp.value.$test1.$test2
					const value = myComp.value.$test1.testValue
					debugger;
				})
			})
			return {myComp}
		}
	});
	
	Vue.createApp(comp).mount("#app");

	</script>
</body>
</html>

Steps to reproduce

  • Open the file and open Console.
  • Click somewhere in the document (it will stop on debugger). There are test2 and testValue variables accesible.
  • Change Vue script link to https://cdn.jsdelivr.net/npm/vue@3.0.0-rc.10/dist/vue.global.prod.js in <head>
  • Repeat point 1 and 2.

The document throws an error the variables are not accessible.

What is expected?

We need to have access to reference of component to call its functions or access the variables inside component. This behavior should be same for production nor development mode.

What is actually happening?

The behavior is inconsistent for production build.

@yyx990803
Copy link
Member

$ is a reserved prefix so you shouldn't be using it.

fa7ab0a now warns such cases and makes your case fail in both dev and prod.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants