Skip to content

Commit 07e264a

Browse files
Merge pull request vuejs#2 from vuejs/dev
merge latest
2 parents 19552a8 + 5e3823a commit 07e264a

File tree

13 files changed

+175
-54
lines changed

13 files changed

+175
-54
lines changed

BACKERS.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
2929
</a>
3030
</td>
3131
<td align="center" valign="middle">
32-
<a href="https://xiaozhuanlan.com" target="_blank">
33-
<img width="222px" src="https://raw.githubusercontent.com/vuejs/cn.vuejs.org/master/themes/vue/source/images/xiaozhuanlan.png">
32+
<a href="https://www.bmqb.com/jobs" target="_blank">
33+
<img width="222px" src="https://raw.githubusercontent.com/vuejs/cn.vuejs.org/master/themes/vue/source/images/bmqb.png">
3434
</a>
3535
</td>
3636
</tr><tr></tr>
@@ -55,8 +55,8 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
5555
</a>
5656
</td>
5757
<td align="center" valign="middle">
58-
<a href="https://www.datacamp.com/careers?utm_source=vuejs&utm_medium=sidebar" target="_blank">
59-
<img width="222px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/datacamp.png">
58+
<a href="https://vehikl.com/" target="_blank">
59+
<img width="222px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/vehikl.png">
6060
</a>
6161
</td>
6262
</tr><tr></tr>
@@ -139,11 +139,6 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
139139
</td>
140140
</tr><tr></tr>
141141
<tr>
142-
<td align="center" valign="middle">
143-
<a href="https://www.bmqb.com/jobs" target="_blank">
144-
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/bmqb.png">
145-
</a>
146-
</td>
147142
<td align="center" valign="middle">
148143
<a href="https://codepilot.ai" target="_blank">
149144
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/codepilot.png">
@@ -159,6 +154,28 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
159154
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/jsguru.png">
160155
</a>
161156
</td>
157+
<td align="center" valign="middle">
158+
<a href="http://aaha.co/" target="_blank">
159+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/aaha.png">
160+
</a>
161+
</td>
162+
<td align="center" valign="middle">
163+
<a href="https://www.valuecoders.com" target="_blank">
164+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/valuecoders.png">
165+
</a>
166+
</td>
167+
<td align="center" valign="middle">
168+
<a href="https://www.nsoft.com/careers/" target="_blank">
169+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/nsoft.png">
170+
</a>
171+
</td>
172+
</tr><tr></tr>
173+
<tr>
174+
<td align="center" valign="middle">
175+
<a href="https://www.pubnub.com/vue-js/" target="_blank">
176+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/pubnub.png">
177+
</a>
178+
</td>
162179
</tr><tr></tr>
163180
</tbody>
164181
</table>

README.md

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
3939
</a>
4040
</td>
4141
<td align="center" valign="middle">
42-
<a href="https://xiaozhuanlan.com" target="_blank">
43-
<img width="222px" src="https://raw.githubusercontent.com/vuejs/cn.vuejs.org/master/themes/vue/source/images/xiaozhuanlan.png">
42+
<a href="https://www.bmqb.com/jobs" target="_blank">
43+
<img width="222px" src="https://raw.githubusercontent.com/vuejs/cn.vuejs.org/master/themes/vue/source/images/bmqb.png">
4444
</a>
4545
</td>
4646
</tr><tr></tr>
@@ -67,8 +67,8 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
6767
</a>
6868
</td>
6969
<td align="center" valign="middle">
70-
<a href="https://www.datacamp.com/careers?utm_source=vuejs&utm_medium=sidebar" target="_blank">
71-
<img width="222px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/datacamp.png">
70+
<a href="https://vehikl.com/" target="_blank">
71+
<img width="222px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/vehikl.png">
7272
</a>
7373
</td>
7474
</tr><tr></tr>
@@ -146,11 +146,6 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
146146
</td>
147147
</tr><tr></tr>
148148
<tr>
149-
<td align="center" valign="middle">
150-
<a href="https://www.bmqb.com/jobs" target="_blank">
151-
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/bmqb.png">
152-
</a>
153-
</td>
154149
<td align="center" valign="middle">
155150
<a href="https://codepilot.ai" target="_blank">
156151
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/codepilot.png">
@@ -166,6 +161,28 @@ Funds donated via Patreon go directly to support Evan You's full-time work on Vu
166161
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/jsguru.png">
167162
</a>
168163
</td>
164+
<td align="center" valign="middle">
165+
<a href="http://aaha.co/" target="_blank">
166+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/aaha.png">
167+
</a>
168+
</td>
169+
<td align="center" valign="middle">
170+
<a href="https://www.valuecoders.com" target="_blank">
171+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/valuecoders.png">
172+
</a>
173+
</td>
174+
<td align="center" valign="middle">
175+
<a href="https://www.nsoft.com/careers/" target="_blank">
176+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/nsoft.png">
177+
</a>
178+
</td>
179+
</tr><tr></tr>
180+
<tr>
181+
<td align="center" valign="middle">
182+
<a href="https://www.pubnub.com/vue-js/" target="_blank">
183+
<img width="148px" src="https://raw.githubusercontent.com/vuejs/vuejs.org/master/themes/vue/source/images/pubnub.png">
184+
</a>
185+
</td>
169186
</tr><tr></tr>
170187
</tbody>
171188
</table>

benchmarks/reorder-list/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<script type="text/x-template" id="t">
1717
<div>
18-
<h1>{{ total }} Components</h1>
18+
<h1>{{ items.length }} Components</h1>
1919
<p>{{ action }} took {{time}}ms.</p>
2020
<button @click="shuffle">shuffle</button>
2121
<button @click="add">add</button>

flow/compiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ declare type ASTText = {
173173

174174
// SFC-parser related declarations
175175

176-
// an object format describing a single-file component.
176+
// an object format describing a single-file component
177177
declare type SFCDescriptor = {
178178
template: ?SFCBlock;
179179
script: ?SFCBlock;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dist/*.js",
1313
"types/*.d.ts"
1414
],
15+
"sideEffects": false,
1516
"scripts": {
1617
"dev": "rollup -w -c scripts/config.js --environment TARGET:web-full-dev",
1718
"dev:cjs": "rollup -w -c scripts/config.js --environment TARGET:web-runtime-cjs",

src/platforms/weex/runtime/modules/class.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* @flow */
22

3-
import { extend } from 'shared/util'
3+
import { extend, isObject } from 'shared/util'
44

55
function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
66
const el = vnode.elm
@@ -15,25 +15,8 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
1515
return
1616
}
1717

18-
const oldClassList = []
19-
// unlike web, weex vnode staticClass is an Array
20-
const oldStaticClass: any = oldData.staticClass
21-
if (oldStaticClass) {
22-
oldClassList.push.apply(oldClassList, oldStaticClass)
23-
}
24-
if (oldData.class) {
25-
oldClassList.push.apply(oldClassList, oldData.class)
26-
}
27-
28-
const classList = []
29-
// unlike web, weex vnode staticClass is an Array
30-
const staticClass: any = data.staticClass
31-
if (staticClass) {
32-
classList.push.apply(classList, staticClass)
33-
}
34-
if (data.class) {
35-
classList.push.apply(classList, data.class)
36-
}
18+
const oldClassList = makeClassList(oldData)
19+
const classList = makeClassList(data)
3720

3821
if (typeof el.setClassList === 'function') {
3922
el.setClassList(classList)
@@ -49,6 +32,22 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
4932
}
5033
}
5134

35+
function makeClassList (data: VNodeData): Array<string> {
36+
const classList = []
37+
// unlike web, weex vnode staticClass is an Array
38+
const staticClass: any = data.staticClass
39+
const dataClass = data.class
40+
if (staticClass) {
41+
classList.push.apply(classList, staticClass)
42+
}
43+
if (Array.isArray(dataClass)) {
44+
classList.push.apply(classList, dataClass)
45+
} else if (isObject(dataClass)) {
46+
classList.push.apply(classList, Object.keys(dataClass).filter(className => dataClass[className]))
47+
}
48+
return classList
49+
}
50+
5251
function getStyle (oldClassList: Array<string>, classList: Array<string>, ctx: Component): Object {
5352
// style is a weex-only injected object
5453
// compiled from <style> tags in weex files

src/server/template-renderer/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ export default class TemplateRenderer {
108108
}
109109

110110
renderStyles (context: Object): string {
111-
const cssFiles = this.clientManifest
112-
? this.clientManifest.all.filter(isCSS)
113-
: []
111+
const initial = this.preloadFiles || []
112+
const async = this.getUsedAsyncFiles(context) || []
113+
const cssFiles = initial.concat(async).filter(({ file }) => isCSS(file))
114114
return (
115115
// render links for css files
116116
(cssFiles.length
117-
? cssFiles.map(file => `<link rel="stylesheet" href="${this.publicPath}/${file}">`).join('')
117+
? cssFiles.map(({ file }) => `<link rel="stylesheet" href="${this.publicPath}/${file}">`).join('')
118118
: '') +
119119
// context.styles is a getter exposed by vue-style-loader which contains
120120
// the inline component styles collected during SSR
@@ -202,10 +202,10 @@ export default class TemplateRenderer {
202202

203203
renderScripts (context: Object): string {
204204
if (this.clientManifest) {
205-
const initial = this.preloadFiles
206-
const async = this.getUsedAsyncFiles(context)
205+
const initial = this.preloadFiles.filter(({ file }) => isJS(file))
206+
const async = (this.getUsedAsyncFiles(context) || []).filter(({ file }) => isJS(file))
207207
const needed = [initial[0]].concat(async || [], initial.slice(1))
208-
return needed.filter(({ file }) => isJS(file)).map(({ file }) => {
208+
return needed.map(({ file }) => {
209209
return `<script src="${this.publicPath}/${file}" defer></script>`
210210
}).join('')
211211
} else {

src/server/webpack-plugin/client.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const hash = require('hash-sum')
22
const uniq = require('lodash.uniq')
3-
import { isJS } from './util'
3+
import { isJS, isCSS, onEmit } from './util'
44

55
export default class VueSSRClientPlugin {
66
constructor (options = {}) {
@@ -10,7 +10,7 @@ export default class VueSSRClientPlugin {
1010
}
1111

1212
apply (compiler) {
13-
compiler.plugin('emit', (compilation, cb) => {
13+
onEmit(compiler, 'vue-client-plugin', (compilation, cb) => {
1414
const stats = compilation.getStats().toJson()
1515

1616
const allFiles = uniq(stats.assets
@@ -19,10 +19,10 @@ export default class VueSSRClientPlugin {
1919
const initialFiles = uniq(Object.keys(stats.entrypoints)
2020
.map(name => stats.entrypoints[name].assets)
2121
.reduce((assets, all) => all.concat(assets), [])
22-
.filter(isJS))
22+
.filter((file) => isJS(file) || isCSS(file)))
2323

2424
const asyncFiles = allFiles
25-
.filter(isJS)
25+
.filter((file) => isJS(file) || isCSS(file))
2626
.filter(file => initialFiles.indexOf(file) < 0)
2727

2828
const manifest = {
@@ -43,7 +43,8 @@ export default class VueSSRClientPlugin {
4343
if (!chunk || !chunk.files) {
4444
return
4545
}
46-
const files = manifest.modules[hash(m.identifier)] = chunk.files.map(fileToIndex)
46+
const id = m.identifier.replace(/\s\w+$/, '') // remove appended hash
47+
const files = manifest.modules[hash(id)] = chunk.files.map(fileToIndex)
4748
// find all asset modules associated with the same chunk
4849
assetModules.forEach(m => {
4950
if (m.chunks.some(id => id === cid)) {

src/server/webpack-plugin/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { validate, isJS } from './util'
1+
import { validate, isJS, onEmit } from './util'
22

33
export default class VueSSRServerPlugin {
44
constructor (options = {}) {
@@ -10,7 +10,7 @@ export default class VueSSRServerPlugin {
1010
apply (compiler) {
1111
validate(compiler)
1212

13-
compiler.plugin('emit', (compilation, cb) => {
13+
onEmit(compiler, 'vue-server-plugin', (compilation, cb) => {
1414
const stats = compilation.getStats().toJson()
1515
const entryName = Object.keys(stats.entrypoints)[0]
1616
const entryInfo = stats.entrypoints[entryName]

src/server/webpack-plugin/util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,14 @@ export const validate = compiler => {
2121
}
2222
}
2323

24+
export const onEmit = (compiler, name, hook) => {
25+
if (compiler.hooks) {
26+
// Webpack >= 4.0.0
27+
compiler.hooks.emit.tapAsync(name, hook)
28+
} else {
29+
// Webpack < 4.0.0
30+
compiler.plugin('emit', hook)
31+
}
32+
}
33+
2434
export { isJS, isCSS } from '../util'

test/weex/cases/cases.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function createEventTestCase (name) {
5454
describe('Usage', () => {
5555
describe('render', () => {
5656
it('sample', createRenderTestCase('render/sample'))
57+
it('class', createRenderTestCase('render/class'))
5758
})
5859

5960
describe('event', () => {

test/weex/cases/render/class.vdom.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
({
2+
type: 'div',
3+
children: [{
4+
type: 'div',
5+
classList: ['box', 'box1']
6+
}, {
7+
type: 'div',
8+
classList: ['box', 'box2']
9+
}, {
10+
type: 'div',
11+
classList: ['box', 'box3']
12+
}, {
13+
type: 'div',
14+
classList: ['box', 'box4']
15+
}, {
16+
type: 'div',
17+
classList: ['box', 'box5']
18+
}]
19+
})

test/weex/cases/render/class.vue

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<template>
2+
<div>
3+
<div :class="class1"></div>
4+
<div :class="class2"></div>
5+
<div class="box" :class="class3"></div>
6+
<div class="box" :class="class4"></div>
7+
<div class="box" :class="{ box5: class5 }"></div>
8+
</div>
9+
</template>
10+
11+
<style scoped>
12+
.box {
13+
width: 100px;
14+
height: 100px;
15+
}
16+
17+
.box1 {
18+
background-color: #DDD;
19+
}
20+
21+
.box2 {
22+
background-color: #CCC;
23+
}
24+
25+
.box3 {
26+
background-color: #BBB;
27+
}
28+
29+
.box4 {
30+
background-color: #AAA;
31+
}
32+
33+
.box5 {
34+
background-color: #999;
35+
}
36+
</style>
37+
38+
<script>
39+
module.exports = {
40+
data () {
41+
return {
42+
class1: ['box', 'box1'],
43+
class2: {
44+
'box': true,
45+
'box1': false,
46+
'box2': true
47+
},
48+
class3: ['box3'],
49+
class4: {
50+
'box4': true
51+
},
52+
class5: true
53+
}
54+
}
55+
}
56+
</script>

0 commit comments

Comments
 (0)