Skip to content

Commit dcc839a

Browse files
author
Evan You
committed
Release-v0.7.3
1 parent a2e287f commit dcc839a

File tree

6 files changed

+123
-70
lines changed

6 files changed

+123
-70
lines changed

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,14 @@ Technically, it provides the **ViewModel** layer of the MVVM pattern, which conn
1010

1111
Philosophically, the goal is to allow the developer to embrace an extremely minimal mental model when dealing with interfaces - there's only one type of object you need to worry about: the ViewModel. It is where all the view logic happens, and manipulating the ViewModel will automatically keep the View and the Model in sync. Actuall DOM manipulations and output formatting are abstracted away into **Directives** and **Filters**.
1212

13-
To learn more, visit [vuejs.org](http://vuejs.org).
13+
For more details, guides and documentations, visit [vuejs.org](http://vuejs.org).
1414

1515
## Browser Support
1616

1717
- Most Webkit/Blink-based browsers
1818
- Firefox 4+
1919
- IE9+ (IE9 needs [classList polyfill](https://github.com/remy/polyfills/blob/master/classList.js) and doesn't support transitions)
2020

21-
## Documentation
22-
23-
Available at [vuejs.org/docs](http://vuejs.org/docs)
24-
2521
## Development
2622

2723
``` bash
@@ -43,9 +39,11 @@ To watch and auto-build dev version during development:
4339
$ grunt watch
4440
```
4541

46-
To test (install [CasperJS](http://casperjs.org/) first):
42+
To test:
4743

4844
``` bash
45+
# if you don't have these yet:
46+
# npm install -g phantomjs casperjs
4947
$ grunt test
5048
```
5149

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"main": "dist/vue.js",
55
"description": "Simple, Fast & Composable MVVM for building interative interfaces",
66
"authors": ["Evan You <[email protected]>"],

component.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"main": "src/main.js",
55
"author": "Evan You <[email protected]>",
66
"description": "Simple, Fast & Composable MVVM for building interative interfaces",

dist/vue.js

+112-58
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
VueJS v0.7.2
3-
(c) 2013 Evan You
2+
VueJS v0.7.3
3+
(c) 2014 Evan You
44
License: MIT
55
*/
66
;(function(){
@@ -441,6 +441,7 @@ ViewModel.transition = function (id, transition) {
441441
}
442442

443443
ViewModel.extend = extend
444+
ViewModel.nextTick = utils.nextTick
444445

445446
/**
446447
* Expose the main ViewModel class
@@ -1042,15 +1043,15 @@ CompilerProto.compile = function (node, root) {
10421043
if (repeatExp = utils.attr(node, 'repeat')) {
10431044

10441045
// repeat block cannot have v-id at the same time.
1045-
directive = Directive.parse(config.attrs.repeat, repeatExp, compiler, node)
1046+
directive = Directive.parse('repeat', repeatExp, compiler, node)
10461047
if (directive) {
10471048
compiler.bindDirective(directive)
10481049
}
10491050

10501051
// v-component has 2nd highest priority
10511052
} else if (!root && (componentExp = utils.attr(node, 'component'))) {
10521053

1053-
directive = Directive.parse(config.attrs.component, componentExp, compiler, node)
1054+
directive = Directive.parse('component', componentExp, compiler, node)
10541055
if (directive) {
10551056
// component directive is a bit different from the others.
10561057
// when it has no argument, it should be treated as a
@@ -1093,28 +1094,44 @@ CompilerProto.compile = function (node, root) {
10931094
* Compile a normal node
10941095
*/
10951096
CompilerProto.compileNode = function (node) {
1096-
var i, j, attrs = node.attributes
1097+
var i, j,
1098+
attrs = node.attributes,
1099+
prefix = config.prefix + '-'
10971100
// parse if has attributes
10981101
if (attrs && attrs.length) {
1099-
var attr, valid, exps, exp
1102+
var attr, isDirective, exps, exp, directive
11001103
// loop through all attributes
11011104
i = attrs.length
11021105
while (i--) {
11031106
attr = attrs[i]
1104-
valid = false
1105-
exps = Directive.split(attr.value)
1106-
// loop through clauses (separated by ",")
1107-
// inside each attribute
1108-
j = exps.length
1109-
while (j--) {
1110-
exp = exps[j]
1111-
var directive = Directive.parse(attr.name, exp, this, node)
1112-
if (directive) {
1113-
valid = true
1114-
this.bindDirective(directive)
1107+
isDirective = false
1108+
1109+
if (attr.name.indexOf(prefix) === 0) {
1110+
// a directive - split, parse and bind it.
1111+
isDirective = true
1112+
exps = Directive.split(attr.value)
1113+
// loop through clauses (separated by ",")
1114+
// inside each attribute
1115+
j = exps.length
1116+
while (j--) {
1117+
exp = exps[j]
1118+
directive = Directive.parse(attr.name.slice(prefix.length), exp, this, node)
1119+
if (directive) {
1120+
this.bindDirective(directive)
1121+
}
1122+
}
1123+
} else {
1124+
// non directive attribute, check interpolation tags
1125+
exp = TextParser.parseAttr(attr.value)
1126+
if (exp) {
1127+
directive = Directive.parse('attr', attr.name + ':' + exp, this, node)
1128+
if (directive) {
1129+
this.bindDirective(directive)
1130+
}
11151131
}
11161132
}
1117-
if (valid) node.removeAttribute(attr.name)
1133+
1134+
if (isDirective) node.removeAttribute(attr.name)
11181135
}
11191136
}
11201137
// recursively compile childNodes
@@ -1132,8 +1149,7 @@ CompilerProto.compileNode = function (node) {
11321149
CompilerProto.compileTextNode = function (node) {
11331150
var tokens = TextParser.parse(node.nodeValue)
11341151
if (!tokens) return
1135-
var dirname = config.attrs.text,
1136-
el, token, directive
1152+
var el, token, directive
11371153
for (var i = 0, l = tokens.length; i < l; i++) {
11381154
token = tokens[i]
11391155
if (token.key) { // a binding
@@ -1146,7 +1162,7 @@ CompilerProto.compileTextNode = function (node) {
11461162
}
11471163
} else { // a binding
11481164
el = document.createTextNode('')
1149-
directive = Directive.parse(dirname, token.key, this, el)
1165+
directive = Directive.parse('text', token.key, this, el)
11501166
if (directive) {
11511167
this.bindDirective(directive)
11521168
}
@@ -1478,7 +1494,15 @@ def(VMProto, '$set', function (key, value) {
14781494
* fire callback with new value
14791495
*/
14801496
def(VMProto, '$watch', function (key, callback) {
1481-
this.$compiler.observer.on('change:' + key, callback)
1497+
var self = this
1498+
function on () {
1499+
var args = arguments
1500+
utils.nextTick(function () {
1501+
callback.apply(self, args)
1502+
})
1503+
}
1504+
callback._fn = on
1505+
self.$compiler.observer.on('change:' + key, on)
14821506
})
14831507

14841508
/**
@@ -1490,7 +1514,7 @@ def(VMProto, '$unwatch', function (key, callback) {
14901514
// by checking the length of arguments
14911515
var args = ['change:' + key],
14921516
ob = this.$compiler.observer
1493-
if (callback) args.push(callback)
1517+
if (callback) args.push(callback._fn)
14941518
ob.off.apply(ob, args)
14951519
})
14961520

@@ -1518,20 +1542,20 @@ def(VMProto, '$broadcast', function () {
15181542
/**
15191543
* emit an event that propagates all the way up to parent VMs.
15201544
*/
1521-
def(VMProto, '$emit', function () {
1545+
def(VMProto, '$dispatch', function () {
15221546
var compiler = this.$compiler,
15231547
emitter = compiler.emitter,
15241548
parent = compiler.parentCompiler
15251549
emitter.emit.apply(emitter, arguments)
15261550
if (parent) {
1527-
parent.vm.$emit.apply(parent.vm, arguments)
1551+
parent.vm.$dispatch.apply(parent.vm, arguments)
15281552
}
15291553
})
15301554

15311555
/**
15321556
* delegate on/off/once to the compiler's emitter
15331557
*/
1534-
;['on', 'off', 'once'].forEach(function (method) {
1558+
;['emit', 'on', 'off', 'once'].forEach(function (method) {
15351559
def(VMProto, '$' + method, function () {
15361560
var emitter = this.$compiler.emitter
15371561
emitter[method].apply(emitter, arguments)
@@ -2016,8 +2040,7 @@ module.exports = {
20162040
}
20172041
});
20182042
require.register("vue/src/directive.js", function(exports, require, module){
2019-
var config = require('./config'),
2020-
utils = require('./utils'),
2043+
var utils = require('./utils'),
20212044
directives = require('./directives'),
20222045
filters = require('./filters'),
20232046

@@ -2219,10 +2242,6 @@ Directive.split = function (exp) {
22192242
*/
22202243
Directive.parse = function (dirname, expression, compiler, node) {
22212244

2222-
var prefix = config.prefix + '-'
2223-
if (dirname.indexOf(prefix) !== 0) return
2224-
dirname = dirname.slice(prefix.length)
2225-
22262245
var dir = compiler.getOption('directives', dirname) || directives[dirname]
22272246
if (!dir) return utils.warn('unknown directive: ' + dirname)
22282247

@@ -2394,26 +2413,40 @@ module.exports = {
23942413
require.register("vue/src/text-parser.js", function(exports, require, module){
23952414
var BINDING_RE = /\{\{(.+?)\}\}/
23962415

2397-
module.exports = {
2416+
/**
2417+
* Parse a piece of text, return an array of tokens
2418+
*/
2419+
function parse (text) {
2420+
if (!BINDING_RE.test(text)) return null
2421+
var m, i, tokens = []
2422+
/* jshint boss: true */
2423+
while (m = text.match(BINDING_RE)) {
2424+
i = m.index
2425+
if (i > 0) tokens.push(text.slice(0, i))
2426+
tokens.push({ key: m[1].trim() })
2427+
text = text.slice(i + m[0].length)
2428+
}
2429+
if (text.length) tokens.push(text)
2430+
return tokens
2431+
}
23982432

2399-
/**
2400-
* Parse a piece of text, return an array of tokens
2401-
*/
2402-
parse: function (text) {
2403-
if (!BINDING_RE.test(text)) return null
2404-
var m, i, tokens = []
2405-
/* jshint boss: true */
2406-
while (m = text.match(BINDING_RE)) {
2407-
i = m.index
2408-
if (i > 0) tokens.push(text.slice(0, i))
2409-
tokens.push({ key: m[1].trim() })
2410-
text = text.slice(i + m[0].length)
2411-
}
2412-
if (text.length) tokens.push(text)
2413-
return tokens
2433+
/**
2434+
* Parse an attribute value with possible interpolation tags
2435+
* return a Directive-friendly expression
2436+
*/
2437+
function parseAttr (attr) {
2438+
var tokens = parse(attr)
2439+
if (!tokens) return null
2440+
var res = [], token
2441+
for (var i = 0, l = tokens.length; i < l; i++) {
2442+
token = tokens[i]
2443+
res.push(token.key || ('"' + token + '"'))
24142444
}
2415-
2445+
return res.join('+')
24162446
}
2447+
2448+
exports.parse = parse
2449+
exports.parseAttr = parseAttr
24172450
});
24182451
require.register("vue/src/deps-parser.js", function(exports, require, module){
24192452
var Emitter = require('./emitter'),
@@ -2426,13 +2459,13 @@ var Emitter = require('./emitter'),
24262459
*/
24272460
function catchDeps (binding) {
24282461
if (binding.isFn) return
2429-
utils.log('\n ' + binding.key)
2462+
utils.log('\n- ' + binding.key)
24302463
var got = utils.hash()
24312464
observer.on('get', function (dep) {
24322465
var has = got[dep.key]
24332466
if (has && has.compiler === dep.compiler) return
24342467
got[dep.key] = dep
2435-
utils.log(' └─ ' + dep.key)
2468+
utils.log(' - ' + dep.key)
24362469
binding.deps.push(dep)
24372470
dep.subs.push(binding)
24382471
})
@@ -2983,7 +3016,7 @@ module.exports = {
29833016
self.hasTrans = el.hasAttribute(config.attrs.transition)
29843017

29853018
// create a comment node as a reference node for DOM insertions
2986-
self.ref = document.createComment(config.prefix + '-repeat-' + self.arg)
3019+
self.ref = document.createComment(config.prefix + '-repeat-' + self.key)
29873020
ctn.insertBefore(self.ref, el)
29883021
ctn.removeChild(el)
29893022

@@ -3206,16 +3239,29 @@ module.exports = {
32063239
? 'change'
32073240
: 'input'
32083241

3209-
// determin the attribute to change when updating
3242+
// determine the attribute to change when updating
32103243
var attr = self.attr = type === 'checkbox'
32113244
? 'checked'
32123245
: (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA')
32133246
? 'value'
32143247
: 'innerHTML'
32153248

3249+
if (self.filters) {
3250+
var compositionLock = false
3251+
this.cLock = function () {
3252+
compositionLock = true
3253+
}
3254+
this.cUnlock = function () {
3255+
compositionLock = false
3256+
}
3257+
el.addEventListener('compositionstart', this.cLock)
3258+
el.addEventListener('compositionend', this.cUnlock)
3259+
}
3260+
32163261
// attach listener
32173262
self.set = self.filters
32183263
? function () {
3264+
if (compositionLock) return
32193265
// if this directive has filters
32203266
// we need to let the vm.$set trigger
32213267
// update() so filters are applied.
@@ -3239,7 +3285,9 @@ module.exports = {
32393285
// no filters, don't let it trigger update()
32403286
self.lock = true
32413287
self.vm.$set(self.key, el[attr])
3242-
self.lock = false
3288+
utils.nextTick(function () {
3289+
self.lock = false
3290+
})
32433291
}
32443292
el.addEventListener(self.event, self.set)
32453293

@@ -3289,10 +3337,15 @@ module.exports = {
32893337
},
32903338

32913339
unbind: function () {
3292-
this.el.removeEventListener(this.event, this.set)
3340+
var el = this.el
3341+
el.removeEventListener(this.event, this.set)
3342+
if (this.filters) {
3343+
el.removeEventListener('compositionstart', this.cLock)
3344+
el.removeEventListener('compositionend', this.cUnlock)
3345+
}
32933346
if (isIE9) {
3294-
this.el.removeEventListener('cut', this.onCut)
3295-
this.el.removeEventListener('keyup', this.onDel)
3347+
el.removeEventListener('cut', this.onCut)
3348+
el.removeEventListener('keyup', this.onDel)
32963349
}
32973350
}
32983351
}
@@ -3338,7 +3391,8 @@ module.exports = {
33383391
require.alias("component-emitter/index.js", "vue/deps/emitter/index.js");
33393392
require.alias("component-emitter/index.js", "emitter/index.js");
33403393

3341-
require.alias("vue/src/main.js", "vue/index.js");if (typeof exports == "object") {
3394+
require.alias("vue/src/main.js", "vue/index.js");
3395+
if (typeof exports == "object") {
33423396
module.exports = require("vue");
33433397
} else if (typeof define == "function" && define.amd) {
33443398
define(function(){ return require("vue"); });

dist/vue.min.js

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue",
3-
"version": "0.7.2",
3+
"version": "0.7.3",
44
"author": {
55
"name": "Evan You",
66
"email": "[email protected]",

0 commit comments

Comments
 (0)