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(patch): static tree as same vnode(#8021) #8499

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jessejyang
Copy link
Contributor

@jessejyang jessejyang commented Jul 16, 2018

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact and migration path for existing applications:

The PR fulfills these requirements:

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:
if change comp1 to comp2, <component :is='comp'> vnode's tag will be changed, but <p> won't, tag is not equal will not be as same vnode.
I am not sure it cause other bugs, forgive me.
thanks for your time.

Close #8021

@jessejyang
Copy link
Contributor Author

jessejyang commented Jul 17, 2018

I am so sorry I find a issue just now.

    const vm = new Vue({
      data: {
        comp: 'comp1',
        list: [
          { id: 0 }
        ]
      },
      components: {
        comp1: {
          template: '<span>comp1</span>'
        },
        comp2: {
          template: '<span>comp2</span>'
        }
      },
      template: `
        <div>
          <div v-for="(item, index) in list" :key="index">
            <component :is='comp' v-once></component>
          </div>
        </div>
      `
    }).$mount()

    expect(vm.$el.textContent).toBe('comp1')

    vm.comp = 'comp2'
    waitForUpdate(() => {
      expect(vm.$el.textContent).toBe('comp1')
      vm.list.push({ id: 1 })
    }).then(() => {
      expect(vm.$el.textContent).toBe('comp1comp2')
      vm.list.unshift({ id: 2 })
    }).then(() => {
      expect(vm.$el.textContent).toBe('comp2comp1comp2')
    }).then(done)

in third test, I got comp1comp2comp2, but :key='item.id' it is ok.
I am not sure is it a bug, cause key is variational.
Thanks

@jessejyang jessejyang changed the title fix(patch): static tree should ba as same vnode(#8021) Aug 2, 2018
@jessejyang jessejyang changed the title fix(patch): static tree should be as same vnode(#8021) Aug 2, 2018
@jessejyang jessejyang changed the title fix(patch): static tree be as same vnode(#8021) Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants