Evan You преди 12 години
родител
ревизия
590a7ee55b
променени са 6 файла, в които са добавени 123 реда и са изтрити 53 реда
  1. 1 1
      bower.json
  2. 1 1
      component.json
  3. 118 48
      dist/vue.js
  4. 1 1
      dist/vue.min.js
  5. 1 1
      package.json
  6. 1 1
      tasks/release.js

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
     "name": "vue",
-    "version": "0.7.0",
+    "version": "0.7.1",
     "main": "dist/vue.js",
     "ignore": [
         ".*",

+ 1 - 1
component.json

@@ -1,6 +1,6 @@
 {
     "name": "vue",
-    "version": "0.7.0",
+    "version": "0.7.1",
     "main": "src/main.js",
     "description": "Data-driven View Models",
     "keywords": ["mvvm", "framework", "data binding"],

+ 118 - 48
dist/vue.js

@@ -377,10 +377,15 @@ var config      = require('./config'),
 /**
  *  Set config options
  */
-ViewModel.config = function (opts) {
-    if (opts) {
+ViewModel.config = function (opts, val) {
+    if (typeof opts === 'string') {
+        if (val === undefined) {
+            return config[opts]
+        } else {
+            config[opts] = val
+        }
+    } else {
         utils.extend(config, opts)
-        if (opts.prefix) updatePrefix()
     }
     return this
 }
@@ -521,29 +526,6 @@ function mergeHook (fn, parentFn) {
     }
 }
 
-/**
- *  Update prefix for some special directives
- *  that are used in compilation.
- */
-var specialAttributes = [
-    'pre',
-    'text',
-    'repeat',
-    'partial',
-    'component',
-    'component-id',
-    'transition'
-]
-
-function updatePrefix () {
-    specialAttributes.forEach(setPrefix)
-}
-
-function setPrefix (attr) {
-    config.attrs[attr] = config.prefix + '-' + attr
-}
-
-updatePrefix()
 module.exports = ViewModel
 });
 require.register("vue/src/emitter.js", function(exports, require, module){
@@ -569,16 +551,42 @@ try {
 module.exports = Emitter
 });
 require.register("vue/src/config.js", function(exports, require, module){
-module.exports = {
+var prefix = 'v',
+    specialAttributes = [
+        'pre',
+        'text',
+        'repeat',
+        'partial',
+        'component',
+        'component-id',
+        'transition'
+    ],
+    config = module.exports = {
+
+        async       : true,
+        debug       : false,
+        silent      : false,
+        enterClass  : 'v-enter',
+        leaveClass  : 'v-leave',
+        attrs       : {},
+
+        get prefix () {
+            return prefix
+        },
+        set prefix (val) {
+            prefix = val
+            updatePrefix()
+        }
+        
+    }
 
-    prefix      : 'v',
-    debug       : false,
-    silent      : false,
-    enterClass  : 'v-enter',
-    leaveClass  : 'v-leave',
-    attrs       : {}
-    
+function updatePrefix () {
+    specialAttributes.forEach(function (attr) {
+        config.attrs[attr] = prefix + '-' + attr
+    })
 }
+
+updatePrefix()
 });
 require.register("vue/src/utils.js", function(exports, require, module){
 var config    = require('./config'),
@@ -588,10 +596,13 @@ var config    = require('./config'),
     console   = window.console,
     ViewModel // late def
 
-var defer =
-    window.webkitRequestAnimationFrame ||
-    window.requestAnimationFrame ||
-    window.setTimeout
+// 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)
 
 /**
  *  Create a prototype-less object
@@ -771,7 +782,7 @@ var utils = module.exports = {
     },
 
     /**
-     * Defer DOM updates
+     *  used to defer batch updates
      */
     nextTick: function (cb) {
         defer(cb, 0)
@@ -1586,6 +1597,9 @@ function getTargetVM (vm, path) {
 module.exports = ViewModel
 });
 require.register("vue/src/binding.js", function(exports, require, module){
+var batcher = require('./batcher'),
+    id = 0
+
 /**
  *  Binding class.
  *
@@ -1594,6 +1608,7 @@ require.register("vue/src/binding.js", function(exports, require, module){
  *  and multiple computed property dependents
  */
 function Binding (compiler, key, isExp, isFn) {
+    this.id = id++
     this.value = undefined
     this.isExp = !!isExp
     this.isFn = isFn
@@ -1603,6 +1618,7 @@ function Binding (compiler, key, isExp, isFn) {
     this.instances = []
     this.subs = []
     this.deps = []
+    this.unbound = false
 }
 
 var BindingProto = Binding.prototype
@@ -1612,9 +1628,13 @@ var BindingProto = Binding.prototype
  */
 BindingProto.update = function (value) {
     this.value = value
+    batcher.queue(this, 'update')
+}
+
+BindingProto._update = function () {
     var i = this.instances.length
     while (i--) {
-        this.instances[i].update(value)
+        this.instances[i].update(this.value)
     }
     this.pub()
 }
@@ -1624,6 +1644,10 @@ BindingProto.update = function (value) {
  *  Force all instances to re-evaluate themselves
  */
 BindingProto.refresh = function () {
+    batcher.queue(this, 'refresh')
+}
+
+BindingProto._refresh = function () {
     var i = this.instances.length
     while (i--) {
         this.instances[i].refresh()
@@ -1646,6 +1670,11 @@ BindingProto.pub = function () {
  *  Unbind the binding, remove itself from all of its dependencies
  */
 BindingProto.unbind = function () {
+    // Indicate this has been unbound.
+    // It's possible this binding will be in
+    // the batcher's flush queue when its owner
+    // compiler has already been destroyed.
+    this.unbound = true
     var i = this.instances.length
     while (i--) {
         this.instances[i].unbind()
@@ -2668,6 +2697,48 @@ function sniffTransitionEndEvent () {
     }
 }
 });
+require.register("vue/src/batcher.js", function(exports, require, module){
+var config = require('./config'),
+    utils = require('./utils'),
+    queue, has, waiting
+
+reset()
+
+exports.queue = function (binding, method) {
+    if (!config.async) {
+        binding['_' + method]()
+        return
+    }
+    if (!has[binding.id]) {
+        queue.push({
+            binding: binding,
+            method: method
+        })
+        has[binding.id] = true
+        if (!waiting) {
+            waiting = true
+            utils.nextTick(flush)
+        }
+    }
+}
+
+function flush () {
+    for (var i = 0; i < queue.length; i++) {
+        var task = queue[i],
+            b = task.binding
+        if (b.unbound) continue
+        b['_' + task.method]()
+        has[b.id] = false
+    }
+    reset()
+}
+
+function reset () {
+    queue = []
+    has = utils.hash()
+    waiting = false
+}
+});
 require.register("vue/src/directives/index.js", function(exports, require, module){
 var utils      = require('../utils'),
     transition = require('../transition')
@@ -3143,15 +3214,14 @@ module.exports = {
                 try {
                     cursorPos = el.selectionStart
                 } catch (e) {}
-                // `input` event has weird updating issue with
-                // International (e.g. Chinese) input methods,
-                // have to use a Timeout to hack around it...
-                setTimeout(function () {
-                    self.vm.$set(self.key, el[attr])
+                self.vm.$set(self.key, el[attr])
+                // since updates are async
+                // we need to reset cursor position async too
+                utils.nextTick(function () {
                     if (cursorPos !== undefined) {
                         el.setSelectionRange(cursorPos, cursorPos)
                     }
-                }, 0)
+                })
             }
             : function () {
                 // no filters, don't let it trigger update()
@@ -3166,9 +3236,9 @@ module.exports = {
         if (isIE9) {
             self.onCut = function () {
                 // cut event fires before the value actually changes
-                setTimeout(function () {
+                utils.nextTick(function () {
                     self.set()
-                }, 0)
+                })
             }
             self.onDel = function (e) {
                 if (e.keyCode === 46 || e.keyCode === 8) {

Файловите разлики са ограничени, защото са твърде много
+ 1 - 1
dist/vue.min.js


+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "vue",
-  "version": "0.7.0",
+  "version": "0.7.1",
   "author": {
     "name": "Evan You",
     "email": "yyx990803@gmail.com",

+ 1 - 1
tasks/release.js

@@ -27,7 +27,7 @@ module.exports = function (grunt) {
     grunt.registerTask('release', function (version) {
 
         var done = this.async(),
-            current = grunt.config('pkg.version'),
+            current = grunt.config('version'),
             next = semver.inc(current, version || 'patch') || version
 
         if (!semver.valid(next)) {

Някои файлове не бяха показани, защото твърде много файлове са промени