Skip to content

Commit

Permalink
Release-v0.7.6
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 19, 2014
1 parent 5f21eed commit bf5c14b
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 64 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue",
"version": "0.7.5",
"version": "0.7.6",
"main": "dist/vue.js",
"description": "Simple, Fast & Composable MVVM for building interative interfaces",
"authors": ["Evan You <yyx990803@gmail.com>"],
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue",
"version": "0.7.5",
"version": "0.7.6",
"main": "src/main.js",
"author": "Evan You <yyx990803@gmail.com>",
"description": "Simple, Fast & Composable MVVM for building interative interfaces",
Expand Down
47 changes: 30 additions & 17 deletions dist/vue.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
VueJS v0.7.5
VueJS v0.7.6
(c) 2014 Evan You
License: MIT
*/
Expand Down Expand Up @@ -603,13 +603,10 @@ var config = require('./config'),
console = window.console,
ViewModel // late def

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

/**
* Create a prototype-less object
Expand Down Expand Up @@ -1145,20 +1142,24 @@ CompilerProto.compileNode = function (node) {
* Compile a text node
*/
CompilerProto.compileTextNode = function (node) {

var tokens = TextParser.parse(node.nodeValue)
if (!tokens) return
var el, token, directive
var el, token, directive, partial, partialId, partialNodes

for (var i = 0, l = tokens.length; i < l; i++) {
token = tokens[i]
if (token.key) { // a binding
if (token.key.charAt(0) === '>') { // a partial
var partialId = token.key.slice(1).trim(),
partial = this.getOption('partials', partialId)
partialId = token.key.slice(1).trim()
partial = this.getOption('partials', partialId)
if (partial) {
el = partial.cloneNode(true)
this.compileNode(el)
// save an Array reference of the partial's nodes
// so we can compile them AFTER appending the fragment
partialNodes = slice.call(el.childNodes)
}
} else { // a binding
} else { // a real binding
el = document.createTextNode('')
directive = Directive.parse('text', token.key, this, el)
if (directive) {
Expand All @@ -1168,7 +1169,20 @@ CompilerProto.compileTextNode = function (node) {
} else { // a plain string
el = document.createTextNode(token)
}

// insert node
node.parentNode.insertBefore(el, node)

// compile partial after appending, because its children's parentNode
// will change from the fragment to the correct parentNode.
// This could affect directives that need access to its element's parentNode.
if (partialNodes) {
for (var j = 0, k = partialNodes.length; j < k; j++) {
this.compile(partialNodes[j])
}
partialNodes = null
}

}
node.parentNode.removeChild(node)
}
Expand Down Expand Up @@ -1332,9 +1346,7 @@ CompilerProto.markComputed = function (binding) {
vm = this.vm
binding.isComputed = true
// bind the accessors to the vm
if (binding.isFn) {
binding.value = utils.bind(value, vm)
} else {
if (!binding.isFn) {
value.$get = utils.bind(value.$get, vm)
if (value.$set) {
value.$set = utils.bind(value.$set, vm)
Expand Down Expand Up @@ -3164,6 +3176,7 @@ module.exports = {

var compiler = this.compiler,
event = this.arg,
isExp = this.binding.isExp,
ownerVM = this.binding.compiler.vm

if (compiler.repeat &&
Expand All @@ -3186,7 +3199,7 @@ module.exports = {
if (target) {
e.el = target
e.targetVM = target.vue_viewmodel
handler.call(ownerVM, e)
handler.call(isExp ? e.targetVM : ownerVM, e)
}
}
dHandler.event = event
Expand Down
4 changes: 2 additions & 2 deletions dist/vue.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions examples/todomvc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1>todos</h1>
<li
class="todo"
v-repeat="todos"
v-if="todoFilter(completed)"
v-if="filterTodo(this)"
v-class="
completed : completed,
editing : this == editedTodo
Expand All @@ -39,20 +39,20 @@ <h1>todos</h1>
class="toggle"
type="checkbox"
v-model="completed"
v-on="change:toggleTodo"
v-on="change: toggleTodo(this)"
>
<label v-text="title" v-on="dblclick:editTodo"></label>
<button class="destroy" v-on="click:removeTodo"></button>
<label v-text="title" v-on="dblclick: editTodo(this)"></label>
<button class="destroy" v-on="click: removeTodo(this)"></button>
</div>
<input
class="edit"
type="text"
v-model="title"
v-todo-focus="this == editedTodo"
v-on="
blur : doneEdit,
keyup : doneEdit | key enter,
keyup : cancelEdit | key esc
blur : doneEdit(this),
keyup : doneEdit(this) | key enter,
keyup : cancelEdit(this) | key esc
"
>
</li>
Expand Down
69 changes: 34 additions & 35 deletions examples/todomvc/js/app.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
var filters = {
all: function () { return true },
active: function (completed) { return !completed },
completed: function (completed) { return completed }
}

Vue.directive('todo-focus', function (value) {
var el = this.el
if (value) {
setTimeout(function () { el.focus() }, 0)
}
})

var app = new Vue({

el: '#todoapp',

directives: {
'todo-focus': function (value) {
if (value) {
var el = this.el
setTimeout(function () { el.focus() }, 0)
}
}
},

created: function () {
this.filters = {
all: function (todo) { todo.completed; return true },
active: function (todo) { return !todo.completed },
completed: function (todo) { return todo.completed }
}
this.updateFilter()
window.addEventListener('hashchange', function () {
app.updateFilter()
})
this.remaining = this.todos.filter(function (todo) {
return !todo.completed
}).length
},

data: {

todos: todoStorage.fetch(),

allDone: {
$get: function () {
return this.remaining === 0
Expand All @@ -41,10 +43,11 @@ var app = new Vue({
},

methods: {

updateFilter: function () {
var filter = location.hash.slice(2)
this.filter = (filter in filters) ? filter : 'all'
this.todoFilter = filters[this.filter]
this.filter = (filter in this.filters) ? filter : 'all'
this.filterTodo = this.filters[this.filter]
},

addTodo: function () {
Expand All @@ -57,44 +60,40 @@ var app = new Vue({
}
},

removeTodo: function (e) {
this.todos.remove(e.targetVM.$data)
this.remaining -= e.targetVM.completed ? 0 : 1
removeTodo: function (todo) {
this.todos.remove(todo.$data)
this.remaining -= todo.completed ? 0 : 1
todoStorage.save()
},

toggleTodo: function (e) {
this.remaining += e.targetVM.completed ? -1 : 1
toggleTodo: function (todo) {
this.remaining += todo.completed ? -1 : 1
todoStorage.save()
},

editTodo: function (e) {
this.beforeEditCache = e.targetVM.title
this.editedTodo = e.targetVM
editTodo: function (todo) {
this.beforeEditCache = todo.title
this.editedTodo = todo
},

doneEdit: function (e) {
doneEdit: function (todo) {
if (!this.editedTodo) return
this.editedTodo = null
e.targetVM.title = e.targetVM.title.trim()
if (!e.targetVM.title) this.removeTodo(e)
todo.title = todo.title.trim()
if (!todo.title) this.removeTodo(todo)
todoStorage.save()
},

cancelEdit: function (e) {
cancelEdit: function (todo) {
this.editedTodo = null
e.targetVM.title = this.beforeEditCache
todo.title = this.beforeEditCache
},

removeCompleted: function () {
this.todos.remove(function (todo) {
return todo.completed
})
todoStorage.save()
}
}
})

window.addEventListener('hashchange', function () {
app.updateFilter()
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue",
"version": "0.7.5",
"version": "0.7.6",
"author": {
"name": "Evan You",
"email": "yyx990803@gmail.com",
Expand Down

0 comments on commit bf5c14b

Please sign in to comment.