vuejs / babel-plugin-transform-vue-jsx

babel plugin for vue 2.0 jsx
1.85k stars 132 forks source link

Spread before other attrs mutates original spreaded object #171

Closed AlbertLucianto closed 5 years ago

AlbertLucianto commented 5 years ago

When data is spreaded before all other attributes (href), those attributes will be included in the data after the render.

Below is a related test case:

it('spread (mixed) should not mutate original data', () => {
  const data = {
    attrs: {
      id: 'hehe'
    }
  }

  const vnode = render(h => (
    <div
      {...data}
      href="huhu" />
  ))

  expect(data.attrs).to.deep.equal({ id: 'hehe' })
})

This yields an error

AssertionError: expected { id: 'hehe', href: 'huhu' } to deeply equal { id: 'hehe' }
      + expected - actual

       {
      -  "href": "huhu"
         "id": "hehe"
       }

However, it doesn't seem the case when there is at least one attribute before the spread.