Skip to content

Commit 81f06af

Browse files
committed
Merge branch 'dev' into tracker-compatibility
2 parents e1ecf7a + 0d6ad12 commit 81f06af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+790
-256
lines changed

.flowconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ module.name_mapper='^weex/\(.*\)$' -> '<PROJECT_ROOT>/src/platforms/weex/\1'
2020
module.name_mapper='^server/\(.*\)$' -> '<PROJECT_ROOT>/src/server/\1'
2121
module.name_mapper='^entries/\(.*\)$' -> '<PROJECT_ROOT>/src/entries/\1'
2222
module.name_mapper='^sfc/\(.*\)$' -> '<PROJECT_ROOT>/src/sfc/\1'
23+
suppress_comment= \\(.\\|\n\\)*\\$flow-disable-line

.github/COMMIT_CONVENTION.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@
44
55
#### Examples
66

7-
Appears under "Features" header, pencil subheader:
7+
Appears under "Features" header, `compiler` subheader:
88

99
```
10-
feat(pencil): add 'graphiteWidth' option
10+
feat(compiler): add 'comments' option
1111
```
1212

13-
Appears under "Bug Fixes" header, graphite subheader, with a link to issue #28:
13+
Appears under "Bug Fixes" header, `v-model` subheader, with a link to issue #28:
1414

1515
```
16-
fix(graphite): stop graphite breaking when width < 0.1
16+
fix(v-model): handle events on blur
1717
1818
close #28
1919
```
2020

2121
Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:
2222

2323
```
24-
perf(pencil): remove graphiteWidth option
24+
perf(core): improve vdom diffing by removing 'foo' option
2525
26-
BREAKING CHANGE: The graphiteWidth option has been removed. The default graphite width of 10mm is always used for performance reason.
26+
BREAKING CHANGE: The 'foo' option has been removed.
2727
```
2828

2929
The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.
3030

3131
```
32-
revert: feat(pencil): add 'graphiteWidth' option
32+
revert: feat(compiler): add 'comments' option
3333
3434
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
3535
```

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,9 @@ test/e2e/reports
1010
test/e2e/screenshots
1111
coverage
1212
RELEASE_NOTE*.md
13+
dist/*.js
14+
packages/vue-server-renderer/basic.js
15+
packages/vue-server-renderer/build.js
16+
packages/vue-server-renderer/server-plugin.js
17+
packages/vue-server-renderer/client-plugin.js
18+
packages/vue-template-compiler/build.js

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<a href="https://www.npmjs.com/package/vue"><img src="https://img.shields.io/npm/dm/vue.svg" alt="Downloads"></a>
77
<a href="https://www.npmjs.com/package/vue"><img src="https://img.shields.io/npm/v/vue.svg" alt="Version"></a>
88
<a href="https://www.npmjs.com/package/vue"><img src="https://img.shields.io/npm/l/vue.svg" alt="License"></a>
9+
<a href="https://gitter.im/vuejs/vue"><img src="https://img.shields.io/gitter/room/nwjs/nw.js.svg" alt="Gitter">
10+
<a href="https://discordapp.com/invite/eKWPvZ9"><img src="https://img.shields.io/badge/chat-on%20discord-7289da.svg" alt="Discord">
911
<br>
1012
<a href="https://saucelabs.com/u/vuejs"><img src="https://saucelabs.com/browser-matrix/vuejs.svg" alt="Sauce Test Status"></a>
1113
</p>
@@ -96,7 +98,7 @@ To check out live examples and docs, visit [vuejs.org](https://vuejs.org).
9698

9799
## Questions
98100

99-
For questions and support please use the [Gitter chat room](https://gitter.im/vuejs/vue) or [the official forum](http://forum.vuejs.org). The issue list of this repo is **exclusively** for bug reports and feature requests.
101+
For questions and support please use the [Discord chat room](https://vue-land.js.org/), [Gitter chat room](https://gitter.im/vuejs/vue), or [the official forum](http://forum.vuejs.org). The issue list of this repo is **exclusively** for bug reports and feature requests.
100102

101103
## Issues
102104

build/release.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ if [[ $REPLY =~ ^[Yy]$ ]]; then
4747

4848
# commit
4949
git add -A
50+
git add -f \
51+
dist/*.js \
52+
!dist/vue.common.min.js \
53+
packages/vue-server-renderer/basic.js \
54+
packages/vue-server-renderer/build.js \
55+
packages/vue-server-renderer/server-plugin.js \
56+
packages/vue-server-renderer/client-plugin.js \
57+
packages/vue-template-compiler/build.js
5058
git commit -m "[build] $VERSION"
5159
npm version $VERSION --message "[release] $VERSION"
5260

flow/compiler.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ declare type CompilerOptions = {
2121

2222
// runtime user-configurable
2323
delimiters?: [string, string]; // template delimiters
24+
25+
// allow user kept comments
26+
comments?: boolean
2427
};
2528

2629
declare type CompiledResult = {
@@ -151,6 +154,7 @@ declare type ASTText = {
151154
type: 3;
152155
text: string;
153156
static?: boolean;
157+
isComment?: boolean;
154158
// 2.4 ssr optimization
155159
ssrOptimizability?: number;
156160
};

flow/component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ declare interface Component {
120120
// renderSlot
121121
_t: (name: string, fallback: ?Array<VNode>, props: ?Object) => ?Array<VNode>;
122122
// apply v-bind object
123-
_b: (data: any, value: any, asProp?: boolean) => VNodeData;
123+
_b: (data: any, tag: string, value: any, asProp: boolean, isSync?: boolean) => VNodeData;
124124
// check custom keyCode
125125
_k: (eventKeyCode: number, key: string, builtInAlias: number | Array<number> | void) => boolean;
126126
// resolve scoped slots

flow/options.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ declare type ComponentOptions = {
6868
name?: string;
6969
extends?: Class<Component> | Object;
7070
delimiters?: [string, string];
71+
comments?: boolean;
7172

7273
// private
7374
_isComponent?: true;

src/compiler/codegen/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ function needsNormalization (el: ASTElement): boolean {
423423
function genNode (node: ASTNode, state: CodegenState): string {
424424
if (node.type === 1) {
425425
return genElement(node, state)
426+
} if (node.type === 3 && node.isComment) {
427+
return genComment(node)
426428
} else {
427429
return genText(node)
428430
}
@@ -435,6 +437,10 @@ export function genText (text: ASTText | ASTExpression): string {
435437
})`
436438
}
437439

440+
export function genComment (comment: ASTText): string {
441+
return `_e('${comment.text}')`
442+
}
443+
438444
function genSlot (el: ASTElement, state: CodegenState): string {
439445
const slotName = el.slotName || '"default"'
440446
const children = genChildren(el, state)

src/compiler/directives/bind.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
export default function bind (el: ASTElement, dir: ASTDirective) {
44
el.wrapData = (code: string) => {
5-
return `_b(${code},'${el.tag}',${dir.value}${
6-
dir.modifiers && dir.modifiers.prop ? ',true' : ''
5+
return `_b(${code},'${el.tag}',${dir.value},${
6+
dir.modifiers && dir.modifiers.prop ? 'true' : 'false'
7+
}${
8+
dir.modifiers && dir.modifiers.sync ? ',true' : ''
79
})`
810
}
911
}

src/compiler/parser/html-parser.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export function parseHTML (html, options) {
8282
const commentEnd = html.indexOf('-->')
8383

8484
if (commentEnd >= 0) {
85+
if (options.shouldKeepComment) {
86+
options.comment(html.substring(4, commentEnd))
87+
}
8588
advance(commentEnd + 3)
8689
continue
8790
}
@@ -222,7 +225,7 @@ export function parseHTML (html, options) {
222225
}
223226
}
224227

225-
const unary = isUnaryTag(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash
228+
const unary = isUnaryTag(tagName) || !!unarySlash
226229

227230
const l = match.attrs.length
228231
const attrs = new Array(l)

src/compiler/parser/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export function parse (
9090
isUnaryTag: options.isUnaryTag,
9191
canBeLeftOpenTag: options.canBeLeftOpenTag,
9292
shouldDecodeNewlines: options.shouldDecodeNewlines,
93+
shouldKeepComment: options.comments,
9394
start (tag, attrs, unary) {
9495
// check namespace.
9596
// inherit parent ns if there is one
@@ -274,6 +275,13 @@ export function parse (
274275
})
275276
}
276277
}
278+
},
279+
comment (text: string) {
280+
currentParent.children.push({
281+
type: 3,
282+
text,
283+
isComment: true
284+
})
277285
}
278286
})
279287
return root

src/core/components/keep-alive.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import { getFirstComponentChild } from 'core/vdom/helpers/index'
55

66
type VNodeCache = { [key: string]: ?VNode };
77

8-
const patternTypes: Array<Function> = [String, RegExp]
8+
const patternTypes: Array<Function> = [String, RegExp, Array]
99

1010
function getComponentName (opts: ?VNodeComponentOptions): ?string {
1111
return opts && (opts.Ctor.options.name || opts.tag)
1212
}
1313

14-
function matches (pattern: string | RegExp, name: string): boolean {
15-
if (typeof pattern === 'string') {
14+
function matches (pattern: string | RegExp | Array<string>, name: string): boolean {
15+
if (Array.isArray(pattern)) {
16+
return pattern.indexOf(name) > -1
17+
} else if (typeof pattern === 'string') {
1618
return pattern.split(',').indexOf(name) > -1
1719
} else if (isRegExp(pattern)) {
1820
return pattern.test(name)
@@ -62,10 +64,10 @@ export default {
6264
},
6365

6466
watch: {
65-
include (val: string | RegExp) {
67+
include (val: string | RegExp | Array<string>) {
6668
pruneCache(this.cache, this._vnode, name => matches(val, name))
6769
},
68-
exclude (val: string | RegExp) {
70+
exclude (val: string | RegExp | Array<string>) {
6971
pruneCache(this.cache, this._vnode, name => !matches(val, name))
7072
}
7173
},

src/core/global-api/use.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ import { toArray } from '../util/index'
44

55
export function initUse (Vue: GlobalAPI) {
66
Vue.use = function (plugin: Function | Object) {
7-
const cid = this.cid
8-
if (!plugin._installed) {
9-
plugin._installed = {}
10-
}
11-
if (plugin._installed[cid]) {
7+
const installedPlugins = (this._installedPlugins || (this._installedPlugins = []))
8+
if (installedPlugins.indexOf(plugin) > -1) {
129
return this
1310
}
11+
1412
// additional parameters
1513
const args = toArray(arguments, 1)
1614
args.unshift(this)
@@ -19,7 +17,7 @@ export function initUse (Vue: GlobalAPI) {
1917
} else if (typeof plugin === 'function') {
2018
plugin.apply(null, args)
2119
}
22-
plugin._installed[cid] = true
20+
installedPlugins.push(plugin)
2321
return this
2422
}
2523
}

src/core/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
1111
Object.defineProperty(Vue.prototype, '$ssrContext', {
1212
get () {
1313
/* istanbul ignore next */
14-
return this.$vnode.ssrContext
14+
return this.$vnode && this.$vnode.ssrContext
1515
}
1616
})
1717

src/core/instance/render-helpers/bind-object-props.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export function bindObjectProps (
1616
data: any,
1717
tag: string,
1818
value: any,
19-
asProp?: boolean
19+
asProp: boolean,
20+
isSync?: boolean
2021
): VNodeData {
2122
if (value) {
2223
if (!isObject(value)) {
@@ -44,6 +45,13 @@ export function bindObjectProps (
4445
}
4546
if (!(key in hash)) {
4647
hash[key] = value[key]
48+
49+
if (isSync) {
50+
const on = data.on || (data.on = {})
51+
on[`update:${key}`] = function ($event) {
52+
value[key] = $event
53+
}
54+
}
4755
}
4856
}
4957
}

src/core/instance/render-helpers/render-slot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function renderSlot (
1515
if (scopedSlotFn) { // scoped slot
1616
props = props || {}
1717
if (bindObject) {
18-
extend(props, bindObject)
18+
props = extend(extend({}, bindObject), props)
1919
}
2020
return scopedSlotFn(props) || fallback
2121
} else {

src/core/observer/array.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ export const arrayMethods = Object.create(arrayProto)
2929
let inserted
3030
switch (method) {
3131
case 'push':
32-
inserted = args
33-
break
3432
case 'unshift':
3533
inserted = args
3634
break

src/core/observer/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
def,
77
isObject,
88
isPlainObject,
9+
isValidArrayIndex,
910
hasProto,
1011
hasOwn,
1112
warn,
@@ -189,7 +190,7 @@ export function defineReactive (
189190
* already exist.
190191
*/
191192
export function set (target: Array<any> | Object, key: any, val: any): any {
192-
if (Array.isArray(target) && (typeof key === 'number' || /^\d+$/.test(key))) {
193+
if (Array.isArray(target) && isValidArrayIndex(key)) {
193194
target.length = Math.max(target.length, key)
194195
target.splice(key, 1, val)
195196
return val
@@ -219,7 +220,7 @@ export function set (target: Array<any> | Object, key: any, val: any): any {
219220
* Delete a property and trigger change if necessary.
220221
*/
221222
export function del (target: Array<any> | Object, key: any) {
222-
if (Array.isArray(target) && typeof key === 'number') {
223+
if (Array.isArray(target) && isValidArrayIndex(key)) {
223224
target.splice(key, 1)
224225
return
225226
}

src/core/observer/watcher.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,28 +93,26 @@ export default class Watcher {
9393
*/
9494
get () {
9595
pushTarget(this)
96+
let value
97+
const vm = this.vm
9698
try {
97-
let value
98-
const vm = this.vm
99+
value = this.getter.call(vm, vm)
100+
} catch (e) {
99101
if (this.user) {
100-
try {
101-
value = this.getter.call(vm, vm)
102-
} catch (e) {
103-
handleError(e, vm, `getter for watcher "${this.expression}"`)
104-
}
102+
handleError(e, vm, `getter for watcher "${this.expression}"`)
105103
} else {
106-
value = this.getter.call(vm, vm)
104+
throw e
107105
}
106+
} finally {
108107
// "touch" every property so they are all tracked as
109108
// dependencies for deep watching
110109
if (this.deep) {
111110
traverse(value)
112111
}
113-
this.cleanupDeps()
114-
return value
115-
} finally {
116112
popTarget()
113+
this.cleanupDeps()
117114
}
115+
return value
118116
}
119117

120118
/**

0 commit comments

Comments
 (0)