Skip to content

Commit bf5c14b

Browse files
committed
Release-v0.7.6
1 parent 5f21eed commit bf5c14b

File tree

7 files changed

+76
-64
lines changed

7 files changed

+76
-64
lines changed

Diff for: bower.json

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

Diff for: component.json

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

Diff for: dist/vue.js

+30-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
VueJS v0.7.5
2+
VueJS v0.7.6
33
(c) 2014 Evan You
44
License: MIT
55
*/
@@ -603,13 +603,10 @@ var config = require('./config'),
603603
console = window.console,
604604
ViewModel // late def
605605

606-
// PhantomJS doesn't support rAF, yet it has the global
607-
// variable exposed. Use setTimeout so tests can work.
608-
var defer = navigator.userAgent.indexOf('PhantomJS') > -1
609-
? window.setTimeout
610-
: (window.webkitRequestAnimationFrame ||
611-
window.requestAnimationFrame ||
612-
window.setTimeout)
606+
var defer =
607+
window.requestAnimationFrame ||
608+
window.webkitRequestAnimationFrame ||
609+
window.setTimeout
613610

614611
/**
615612
* Create a prototype-less object
@@ -1145,20 +1142,24 @@ CompilerProto.compileNode = function (node) {
11451142
* Compile a text node
11461143
*/
11471144
CompilerProto.compileTextNode = function (node) {
1145+
11481146
var tokens = TextParser.parse(node.nodeValue)
11491147
if (!tokens) return
1150-
var el, token, directive
1148+
var el, token, directive, partial, partialId, partialNodes
1149+
11511150
for (var i = 0, l = tokens.length; i < l; i++) {
11521151
token = tokens[i]
11531152
if (token.key) { // a binding
11541153
if (token.key.charAt(0) === '>') { // a partial
1155-
var partialId = token.key.slice(1).trim(),
1156-
partial = this.getOption('partials', partialId)
1154+
partialId = token.key.slice(1).trim()
1155+
partial = this.getOption('partials', partialId)
11571156
if (partial) {
11581157
el = partial.cloneNode(true)
1159-
this.compileNode(el)
1158+
// save an Array reference of the partial's nodes
1159+
// so we can compile them AFTER appending the fragment
1160+
partialNodes = slice.call(el.childNodes)
11601161
}
1161-
} else { // a binding
1162+
} else { // a real binding
11621163
el = document.createTextNode('')
11631164
directive = Directive.parse('text', token.key, this, el)
11641165
if (directive) {
@@ -1168,7 +1169,20 @@ CompilerProto.compileTextNode = function (node) {
11681169
} else { // a plain string
11691170
el = document.createTextNode(token)
11701171
}
1172+
1173+
// insert node
11711174
node.parentNode.insertBefore(el, node)
1175+
1176+
// compile partial after appending, because its children's parentNode
1177+
// will change from the fragment to the correct parentNode.
1178+
// This could affect directives that need access to its element's parentNode.
1179+
if (partialNodes) {
1180+
for (var j = 0, k = partialNodes.length; j < k; j++) {
1181+
this.compile(partialNodes[j])
1182+
}
1183+
partialNodes = null
1184+
}
1185+
11721186
}
11731187
node.parentNode.removeChild(node)
11741188
}
@@ -1332,9 +1346,7 @@ CompilerProto.markComputed = function (binding) {
13321346
vm = this.vm
13331347
binding.isComputed = true
13341348
// bind the accessors to the vm
1335-
if (binding.isFn) {
1336-
binding.value = utils.bind(value, vm)
1337-
} else {
1349+
if (!binding.isFn) {
13381350
value.$get = utils.bind(value.$get, vm)
13391351
if (value.$set) {
13401352
value.$set = utils.bind(value.$set, vm)
@@ -3164,6 +3176,7 @@ module.exports = {
31643176

31653177
var compiler = this.compiler,
31663178
event = this.arg,
3179+
isExp = this.binding.isExp,
31673180
ownerVM = this.binding.compiler.vm
31683181

31693182
if (compiler.repeat &&
@@ -3186,7 +3199,7 @@ module.exports = {
31863199
if (target) {
31873200
e.el = target
31883201
e.targetVM = target.vue_viewmodel
3189-
handler.call(ownerVM, e)
3202+
handler.call(isExp ? e.targetVM : ownerVM, e)
31903203
}
31913204
}
31923205
dHandler.event = event

Diff for: dist/vue.min.js

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

Diff for: examples/todomvc/index.html

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1>todos</h1>
2828
<li
2929
class="todo"
3030
v-repeat="todos"
31-
v-if="todoFilter(completed)"
31+
v-if="filterTodo(this)"
3232
v-class="
3333
completed : completed,
3434
editing : this == editedTodo
@@ -39,20 +39,20 @@ <h1>todos</h1>
3939
class="toggle"
4040
type="checkbox"
4141
v-model="completed"
42-
v-on="change:toggleTodo"
42+
v-on="change: toggleTodo(this)"
4343
>
44-
<label v-text="title" v-on="dblclick:editTodo"></label>
45-
<button class="destroy" v-on="click:removeTodo"></button>
44+
<label v-text="title" v-on="dblclick: editTodo(this)"></label>
45+
<button class="destroy" v-on="click: removeTodo(this)"></button>
4646
</div>
4747
<input
4848
class="edit"
4949
type="text"
5050
v-model="title"
5151
v-todo-focus="this == editedTodo"
5252
v-on="
53-
blur : doneEdit,
54-
keyup : doneEdit | key enter,
55-
keyup : cancelEdit | key esc
53+
blur : doneEdit(this),
54+
keyup : doneEdit(this) | key enter,
55+
keyup : cancelEdit(this) | key esc
5656
"
5757
>
5858
</li>

Diff for: examples/todomvc/js/app.js

+34-35
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,33 @@
1-
var filters = {
2-
all: function () { return true },
3-
active: function (completed) { return !completed },
4-
completed: function (completed) { return completed }
5-
}
6-
7-
Vue.directive('todo-focus', function (value) {
8-
var el = this.el
9-
if (value) {
10-
setTimeout(function () { el.focus() }, 0)
11-
}
12-
})
13-
141
var app = new Vue({
152

163
el: '#todoapp',
174

5+
directives: {
6+
'todo-focus': function (value) {
7+
if (value) {
8+
var el = this.el
9+
setTimeout(function () { el.focus() }, 0)
10+
}
11+
}
12+
},
13+
1814
created: function () {
15+
this.filters = {
16+
all: function (todo) { todo.completed; return true },
17+
active: function (todo) { return !todo.completed },
18+
completed: function (todo) { return todo.completed }
19+
}
1920
this.updateFilter()
21+
window.addEventListener('hashchange', function () {
22+
app.updateFilter()
23+
})
2024
this.remaining = this.todos.filter(function (todo) {
2125
return !todo.completed
2226
}).length
2327
},
2428

2529
data: {
26-
2730
todos: todoStorage.fetch(),
28-
2931
allDone: {
3032
$get: function () {
3133
return this.remaining === 0
@@ -41,10 +43,11 @@ var app = new Vue({
4143
},
4244

4345
methods: {
46+
4447
updateFilter: function () {
4548
var filter = location.hash.slice(2)
46-
this.filter = (filter in filters) ? filter : 'all'
47-
this.todoFilter = filters[this.filter]
49+
this.filter = (filter in this.filters) ? filter : 'all'
50+
this.filterTodo = this.filters[this.filter]
4851
},
4952

5053
addTodo: function () {
@@ -57,44 +60,40 @@ var app = new Vue({
5760
}
5861
},
5962

60-
removeTodo: function (e) {
61-
this.todos.remove(e.targetVM.$data)
62-
this.remaining -= e.targetVM.completed ? 0 : 1
63+
removeTodo: function (todo) {
64+
this.todos.remove(todo.$data)
65+
this.remaining -= todo.completed ? 0 : 1
6366
todoStorage.save()
6467
},
6568

66-
toggleTodo: function (e) {
67-
this.remaining += e.targetVM.completed ? -1 : 1
69+
toggleTodo: function (todo) {
70+
this.remaining += todo.completed ? -1 : 1
6871
todoStorage.save()
6972
},
7073

71-
editTodo: function (e) {
72-
this.beforeEditCache = e.targetVM.title
73-
this.editedTodo = e.targetVM
74+
editTodo: function (todo) {
75+
this.beforeEditCache = todo.title
76+
this.editedTodo = todo
7477
},
7578

76-
doneEdit: function (e) {
79+
doneEdit: function (todo) {
7780
if (!this.editedTodo) return
7881
this.editedTodo = null
79-
e.targetVM.title = e.targetVM.title.trim()
80-
if (!e.targetVM.title) this.removeTodo(e)
82+
todo.title = todo.title.trim()
83+
if (!todo.title) this.removeTodo(todo)
8184
todoStorage.save()
8285
},
8386

84-
cancelEdit: function (e) {
87+
cancelEdit: function (todo) {
8588
this.editedTodo = null
86-
e.targetVM.title = this.beforeEditCache
89+
todo.title = this.beforeEditCache
8790
},
88-
91+
8992
removeCompleted: function () {
9093
this.todos.remove(function (todo) {
9194
return todo.completed
9295
})
9396
todoStorage.save()
9497
}
9598
}
96-
})
97-
98-
window.addEventListener('hashchange', function () {
99-
app.updateFilter()
10099
})

Diff for: package.json

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

0 commit comments

Comments
 (0)