Skip to content

Commit 3fe55e0

Browse files
committed
Prepare for first release (update deps, fix all tests, add extra tests)
1 parent fb68d80 commit 3fe55e0

File tree

31 files changed

+8010
-4737
lines changed

31 files changed

+8010
-4737
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"test": "lerna run test"
77
},
88
"devDependencies": {
9-
"lerna": "^2.9.1"
9+
"lerna": "^3.1.4"
1010
}
1111
}

Diff for: packages/babel-helper-vue-jsx-merge-props/package.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
"prepublish": "yarn build"
1616
},
1717
"devDependencies": {
18-
"@babel/core": "^7.0.0-beta.49",
19-
"@babel/preset-env": "^7.0.0-beta.49",
18+
"@babel/core": "^7.0.0-rc.3",
19+
"@babel/preset-env": "^7.0.0-rc.3",
2020
"ava": "^0.25.0",
21-
"nyc": "^11.8.0",
22-
"rollup": "^0.59.4",
23-
"rollup-plugin-babel": "beta",
24-
"rollup-plugin-istanbul": "^2.0.1",
25-
"rollup-plugin-uglify-es": "^0.0.1"
21+
"nyc": "^12.0.2",
22+
"rollup": "^0.65.0",
23+
"rollup-plugin-babel": "4.0.0-beta.8",
24+
"rollup-plugin-babel-minify": "^5.0.0",
25+
"rollup-plugin-istanbul": "^2.0.1"
2626
},
2727
"nyc": {
2828
"exclude": ["dist", "test"]

Diff for: packages/babel-helper-vue-jsx-merge-props/rollup.config.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { rollup } from 'rollup'
21
import babel from 'rollup-plugin-babel'
3-
import uglify from 'rollup-plugin-uglify-es'
2+
import minify from 'rollup-plugin-babel-minify'
43

54
export default {
65
input: 'src/index.js',
@@ -21,7 +20,7 @@ export default {
2120
],
2221
],
2322
}),
24-
uglify(),
23+
minify({ comments: false }),
2524
],
2625
output: [
2726
{

Diff for: packages/babel-helper-vue-jsx-merge-props/yarn.lock

+844-557
Large diffs are not rendered by default.

Diff for: packages/babel-plugin-transform-vue-jsx/package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@
1818
"prepublish": "yarn build"
1919
},
2020
"devDependencies": {
21-
"@babel/cli": "^7.0.0-beta.49",
22-
"@babel/core": "^7.0.0-beta.49",
23-
"@babel/preset-env": "^7.0.0-beta.49",
21+
"@babel/cli": "^7.0.0-rc.3",
22+
"@babel/core": "^7.0.0-rc.3",
23+
"@babel/preset-env": "^7.0.0-rc.3",
24+
"@vue/test-utils": "^1.0.0-beta.24",
2425
"ava": "^0.25.0",
25-
"jsdom": "^11.11.0",
2626
"jsdom-global": "^3.0.2",
27-
"nyc": "^11.8.0",
28-
"rollup": "^0.59.4",
29-
"rollup-plugin-babel": "beta",
27+
"nyc": "^12.0.2",
28+
"rollup": "^0.65.0",
29+
"rollup-plugin-babel": "4.0.0-beta.8",
30+
"rollup-plugin-babel-minify": "^5.0.0",
3031
"rollup-plugin-istanbul": "^2.0.1",
31-
"rollup-plugin-uglify-es": "^0.0.1",
32-
"vue": "^2.5.16",
33-
"vue-template-compiler": "^2.5.16",
34-
"vue-test-utils": "^1.0.0-beta.11"
32+
"vue": "^2.5.17"
3533
},
3634
"dependencies": {
37-
"@babel/helper-module-imports": "^7.0.0-beta.49",
38-
"@babel/plugin-syntax-jsx": "^7.0.0-beta.49",
39-
"@vuejs/babel-helper-vue-jsx-merge-props": "^0.1.0",
40-
"lodash.kebabcase": "^4.1.1"
35+
"@babel/helper-module-imports": "^7.0.0-rc.3",
36+
"@babel/plugin-syntax-jsx": "^7.0.0-rc.3",
37+
"@vue/babel-helper-vue-jsx-merge-props": "^0.1.0",
38+
"jsdom": "^12.0.0",
39+
"lodash.kebabcase": "^4.1.1",
40+
"vue-template-compiler": "^2.5.17"
4141
},
4242
"nyc": {
4343
"exclude": [

Diff for: packages/babel-plugin-transform-vue-jsx/rollup.config.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { rollup } from 'rollup'
21
import babel from 'rollup-plugin-babel'
3-
import uglify from 'rollup-plugin-uglify-es'
2+
import minify from 'rollup-plugin-babel-minify'
43

54
export default {
65
input: 'src/index.js',
@@ -19,7 +18,7 @@ export default {
1918
],
2019
],
2120
}),
22-
uglify(),
21+
minify({ comments: false }),
2322
],
2423
output: [
2524
{

Diff for: packages/babel-plugin-transform-vue-jsx/src/index.js

+17-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { addDefault } from '@babel/helper-module-imports'
33
import kebabcase from 'lodash.kebabcase'
44

55
const xlinkRE = /^xlink([A-Z])/
6-
const directiveRE = /^v-/
76
const rootAttributes = ['class', 'style', 'key', 'ref', 'refInFor', 'slot', 'scopedSlots', 'model']
87
const prefixes = ['props', 'domProps', 'on', 'nativeOn', 'hook', 'attrs']
98
const domPropsValueElements = ['input', 'textarea', 'option', 'select']
@@ -92,7 +91,22 @@ const getChildren = (t, paths) =>
9291
*/
9392
const addAttribute = (t, attributes, type, value) => {
9493
if (attributes[type]) {
95-
attributes[type].properties.push(value)
94+
let exists = false
95+
if (t.isObjectProperty(value) && (type === 'on' || type === 'nativeOn')) {
96+
attributes[type].properties.forEach(property => {
97+
if (t.isObjectProperty(property) && property.key.value === value.key.value) {
98+
if (t.isArrayExpression(property.value)) {
99+
property.value.elements.push(value.value)
100+
} else {
101+
property.value = t.arrayExpression([property.value, value.value])
102+
}
103+
exists = true
104+
}
105+
})
106+
}
107+
if (!exists) {
108+
attributes[type].properties.push(value)
109+
}
96110
} else {
97111
attributes[type] = t.objectExpression([value])
98112
}
@@ -317,7 +331,7 @@ const transformJSXElement = (t, path) => {
317331
const args = [tag]
318332
if (attributes) {
319333
if (t.isArrayExpression(attributes)) {
320-
const helper = addDefault(path, '@vuejs/babel-helper-vue-jsx-merge-props', { nameHint: '_mergeJSXProps' })
334+
const helper = addDefault(path, '@vue/babel-helper-vue-jsx-merge-props', { nameHint: '_mergeJSXProps' })
321335
args.push(t.callExpression(helper, [attributes]))
322336
} else {
323337
args.push(attributes)

Diff for: packages/babel-plugin-transform-vue-jsx/test/functional.js

+41-30
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import 'jsdom-global/register'
12
import test from 'ava'
2-
require('jsdom-global')()
3-
const { shallow } = require('vue-test-utils')
3+
import { shallowMount } from '@vue/test-utils'
4+
import Vue from 'vue'
45

56
const it = () => {}
67

78
test('Contains text', t => {
8-
const wrapper = shallow({
9+
const wrapper = shallowMount({
910
render(h) {
1011
return <div>test</div>
1112
},
@@ -17,7 +18,7 @@ test('Contains text', t => {
1718

1819
test('Binds text', t => {
1920
const text = 'foo'
20-
const wrapper = shallow({
21+
const wrapper = shallowMount({
2122
render(h) {
2223
return <div>{text}</div>
2324
},
@@ -28,7 +29,7 @@ test('Binds text', t => {
2829
})
2930

3031
test('Extracts attrs', t => {
31-
const wrapper = shallow({
32+
const wrapper = shallowMount({
3233
render(h) {
3334
return <div id="hi" dir="ltr" />
3435
},
@@ -40,7 +41,7 @@ test('Extracts attrs', t => {
4041

4142
test('Binds attrs', t => {
4243
const id = 'foo'
43-
const wrapper = shallow({
44+
const wrapper = shallowMount({
4445
render(h) {
4546
return <div id={id} />
4647
},
@@ -50,7 +51,7 @@ test('Binds attrs', t => {
5051
})
5152

5253
test('Omits attrs if possible', t => {
53-
const wrapper = shallow({
54+
const wrapper = shallowMount({
5455
render(h) {
5556
return <div>test</div>
5657
},
@@ -60,7 +61,7 @@ test('Omits attrs if possible', t => {
6061
})
6162

6263
test('Omits children if possible', t => {
63-
const wrapper = shallow({
64+
const wrapper = shallowMount({
6465
render(h) {
6566
return <div />
6667
},
@@ -70,7 +71,7 @@ test('Omits children if possible', t => {
7071
})
7172

7273
test('Handles top-level special attrs', t => {
73-
const wrapper = shallow({
74+
const wrapper = shallowMount({
7475
render(h) {
7576
return <div class="foo" style="bar" key="key" ref="ref" refInFor slot="slot" />
7677
},
@@ -85,7 +86,7 @@ test('Handles top-level special attrs', t => {
8586

8687
test('Handles nested properties', t => {
8788
const noop = _ => _
88-
const wrapper = shallow({
89+
const wrapper = shallowMount({
8990
render(h) {
9091
return (
9192
<div
@@ -107,7 +108,7 @@ test('Handles nested properties', t => {
107108

108109
test('Handles nested properties (camelCase)', t => {
109110
const noop = _ => _
110-
const wrapper = shallow({
111+
const wrapper = shallowMount({
111112
render(h) {
112113
return (
113114
<div propsOnSuccess={noop} onClick={noop} onCamelCase={noop} domPropsInnerHTML="<p>hi</p>" hookInsert={noop} />
@@ -122,7 +123,7 @@ test('Handles nested properties (camelCase)', t => {
122123
})
123124

124125
test('Supports data attribute', t => {
125-
const wrapper = shallow({
126+
const wrapper = shallowMount({
126127
render(h) {
127128
return <div data-id="1" />
128129
},
@@ -132,8 +133,8 @@ test('Supports data attribute', t => {
132133
})
133134

134135
test('Handles identifier tag name as components', t => {
135-
const Test = {}
136-
const wrapper = shallow({
136+
const Test = { render: () => null }
137+
const wrapper = shallowMount({
137138
render(h) {
138139
return <Test />
139140
},
@@ -143,8 +144,12 @@ test('Handles identifier tag name as components', t => {
143144
})
144145

145146
test('Works for components with children', t => {
146-
const Test = {}
147-
const wrapper = shallow({
147+
const Test = {
148+
render(h) {
149+
h('div')
150+
},
151+
}
152+
const wrapper = shallowMount({
148153
render(h) {
149154
return (
150155
<Test>
@@ -164,7 +169,7 @@ test('Binds things in thunk with correct this context', t => {
164169
return <div>{this.$slots.default}</div>
165170
},
166171
}
167-
const wrapper = shallow({
172+
const wrapper = shallowMount({
168173
data: () => ({ test: 'foo' }),
169174
render(h) {
170175
return <Test>{this.test}</Test>
@@ -178,7 +183,7 @@ test('Spread (single object expression)', t => {
178183
const props = {
179184
innerHTML: 2,
180185
}
181-
const wrapper = shallow({
186+
const wrapper = shallowMount({
182187
render(h) {
183188
return <div {...{ props }} />
184189
},
@@ -208,7 +213,7 @@ test('Spread (mixed)', t => {
208213
},
209214
class: ['a', 'b'],
210215
}
211-
const wrapper = shallow({
216+
const wrapper = shallowMount({
212217
render(h) {
213218
return (
214219
<div
@@ -232,19 +237,25 @@ test('Spread (mixed)', t => {
232237
})
233238

234239
test('Custom directives', t => {
235-
const wrapper = shallow({
240+
const directive = {
241+
inserted() {},
242+
}
243+
Vue.directive('test', directive)
244+
Vue.directive('other', directive)
245+
246+
const wrapper = shallowMount({
236247
render(h) {
237248
return <div v-test={123} vOther={234} />
238249
},
239250
})
240251

241252
t.is(wrapper.vnode.data.directives.length, 2)
242-
t.deepEqual(wrapper.vnode.data.directives[0], { def: undefined, modifiers: {}, name: 'test', value: 123 })
243-
t.deepEqual(wrapper.vnode.data.directives[1], { def: undefined, modifiers: {}, name: 'other', value: 234 })
253+
t.deepEqual(wrapper.vnode.data.directives[0], { def: directive, modifiers: {}, name: 'test', value: 123 })
254+
t.deepEqual(wrapper.vnode.data.directives[1], { def: directive, modifiers: {}, name: 'other', value: 234 })
244255
})
245256

246257
test('xlink:href', t => {
247-
const wrapper = shallow({
258+
const wrapper = shallowMount({
248259
render(h) {
249260
return <use xlinkHref={'#name'} />
250261
},
@@ -254,7 +265,7 @@ test('xlink:href', t => {
254265
})
255266

256267
test('Merge class', t => {
257-
const wrapper = shallow({
268+
const wrapper = shallowMount({
258269
render(h) {
259270
return <div class="a" {...{ class: 'b' }} />
260271
},
@@ -273,7 +284,7 @@ test('JSXMemberExpression', t => {
273284
},
274285
},
275286
}
276-
const wrapper = shallow({
287+
const wrapper = shallowMount({
277288
render(h) {
278289
return <a.b.cmp />
279290
},
@@ -284,7 +295,7 @@ test('JSXMemberExpression', t => {
284295

285296
test('JSXSpreadChild', t => {
286297
const a = ['1', '2']
287-
const wrapper = shallow({
298+
const wrapper = shallowMount({
288299
render(h) {
289300
return <div>{...a}</div>
290301
},
@@ -295,7 +306,7 @@ test('JSXSpreadChild', t => {
295306

296307
test('domProps input[value]', t => {
297308
const val = 'foo'
298-
const wrapper = shallow({
309+
const wrapper = shallowMount({
299310
render(h) {
300311
return <input type="text" value={val} />
301312
},
@@ -307,7 +318,7 @@ test('domProps input[value]', t => {
307318

308319
test('domProps option[selected]', t => {
309320
const val = 'foo'
310-
const wrapper = shallow({
321+
const wrapper = shallowMount({
311322
render(h) {
312323
return <option selected={val} />
313324
},
@@ -318,7 +329,7 @@ test('domProps option[selected]', t => {
318329

319330
test('domProps input[checked]', t => {
320331
const val = 'foo'
321-
const wrapper = shallow({
332+
const wrapper = shallowMount({
322333
render(h) {
323334
return <input checked={val} />
324335
},
@@ -329,7 +340,7 @@ test('domProps input[checked]', t => {
329340

330341
test('domProps video[muted]', t => {
331342
const val = 'foo'
332-
const wrapper = shallow({
343+
const wrapper = shallowMount({
333344
render(h) {
334345
return <video muted={val} />
335346
},

0 commit comments

Comments
 (0)