Skip to content

Commit 67f9788

Browse files
committed
feat: transpile object rest spread with Object.assign by default
1 parent 03e1e75 commit 67f9788

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ This is an internal package used by `vue-loader` and `vueify`. It processes the
22

33
1. add support to ES2015 features in template expressions via Buble. (see [supported features here](https://buble.surge.sh/guide/#supported-features)).
44

5+
**Note:** since version 1.8.0, object rest spread usage inside templates are transpiled to `Object.assign` calls by default. This means if you need to support IE, you will need to polyfill `Object.assign`. (Latest version of Vue CLI will do this for you).
6+
57
2. remove the `with` block inside render functions to make it strict-mode compliant. This is performed only at build time so that the base template compiler can be extremely small and lightweight.
68

79
The buble implementation is built from a fork at https://github.com/yyx990803/buble

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ var defaultOptions = {
88
stripWith: true,
99
// custom feature ensures with context targets functional render
1010
stripWithFunctional: false
11-
}
11+
},
12+
// allow spread...
13+
objectAssign: 'Object.assign'
1214
}
1315

1416
module.exports = function transpile (code, opts) {

test.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test('should work', () => {
99
<div>
1010
<div>{{ foo }} {{ process.env.BAR }}</div>
1111
<div v-for="{ name } in items">{{ name }}</div>
12+
<div v-bind="{ ...a, ...b }"/>
1213
</div>
1314
`)
1415

@@ -24,11 +25,17 @@ test('should work', () => {
2425
items: [
2526
{ name: 'foo' },
2627
{ name: 'bar' }
27-
]
28+
],
29+
a: { id: 'foo' },
30+
b: { class: 'bar' }
2831
},
2932
render: toFunction(res.render),
3033
staticRenderFns: res.staticRenderFns.map(toFunction)
3134
}).$mount()
3235

33-
expect(vm.$el.innerHTML).toMatch(`<div>hello bar</div> <div>foo</div><div>bar</div>`)
36+
expect(vm.$el.innerHTML).toMatch(
37+
`<div>hello bar</div> ` +
38+
`<div>foo</div><div>bar</div> ` +
39+
`<div id="foo" class="bar"></div>`
40+
)
3441
})

0 commit comments

Comments
 (0)