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

pass query.id as an option to addId in style-rewriter #237

Merged
merged 1 commit into from
May 22, 2016
Merged

pass query.id as an option to addId in style-rewriter #237

merged 1 commit into from
May 22, 2016

Conversation

cjxgm
Copy link

@cjxgm cjxgm commented May 22, 2016

Global variables (currentId) should not be used for passing arguments to "execute-later" async functions.

This patch fixes a hard-to-reproduce bug, which is described below.

For example, I have two vue component foo.vue and bar.vue and they both have the same content as below:

<template>
  <div class="hello"></div>
</template>
<style scoped>
  .hello { display: none; }
</style>

When I use them like this:

<foo></foo>
<bar></bar>

It produces HTML as following

<div class="hello" _v-1234567></div>
<div class="hello" _v-2222222></div>

This is correct. But on the style side, you get the following with some setup

.hello[_v-2222222] { display: none; }    /* from foo.vue, the id should be _v-1234567 */
.hello[_v-2222222] { display: none; }    /* from bar.vue, correct */

and the following with some other setup

.hello[] { display: none; }    /* from foo.vue, there should be id in brackets */
.hello[] { display: none; }    /* from bar.vue, there should be id in brackets */

The expected style is

.hello[_v-1234567] { display: none; }    /* from foo.vue */
.hello[_v-2222222] { display: none; }    /* from bar.vue */

You won't reproduce the bug by replaying what I said above. It's only a simplified description of what I've observed from our quite big codebase with complex dependencies. But you can reason about it.

- removed global variable "currentId"
- query.id is passed as an option to addId
@yyx990803 yyx990803 merged commit 8951234 into vuejs:master May 22, 2016
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.

2 participants