فهرست منبع

[build] 1.0.20

Evan You 10 سال پیش
والد
کامیت
4be8eb4935
4فایلهای تغییر یافته به همراه132 افزوده شده و 82 حذف شده
  1. 65 40
      dist/vue.common.js
  2. 65 40
      dist/vue.js
  3. 1 1
      dist/vue.min.js
  4. 1 1
      src/index.js

+ 65 - 40
dist/vue.common.js

@@ -1,5 +1,5 @@
 /*!
 /*!
- * Vue.js v1.0.19
+ * Vue.js v1.0.20
  * (c) 2016 Evan You
  * (c) 2016 Evan You
  * Released under the MIT License.
  * Released under the MIT License.
  */
  */
@@ -2042,6 +2042,24 @@ def(arrayProto, '$remove', function $remove(item) {
 
 
 var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
 var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
 
 
+/**
+ * By default, when a reactive property is set, the new value is
+ * also converted to become reactive. However in certain cases, e.g.
+ * v-for scope alias and props, we don't want to force conversion
+ * because the value may be a nested value under a frozen data structure.
+ *
+ * So whenever we want to set a reactive property without forcing
+ * conversion on the new value, we wrap that call inside this function.
+ */
+
+var shouldConvert = true;
+
+function withoutConversion(fn) {
+  shouldConvert = false;
+  fn();
+  shouldConvert = true;
+}
+
 /**
 /**
  * Observer class that are attached to each observed
  * Observer class that are attached to each observed
  * object. Once attached, the observer converts target
  * object. Once attached, the observer converts target
@@ -2179,7 +2197,7 @@ function observe(value, vm) {
   var ob;
   var ob;
   if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
   if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
     ob = value.__ob__;
     ob = value.__ob__;
-  } else if ((isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
+  } else if (shouldConvert && (isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
     ob = new Observer(value);
     ob = new Observer(value);
   }
   }
   if (ob && vm) {
   if (ob && vm) {
@@ -2194,10 +2212,9 @@ function observe(value, vm) {
  * @param {Object} obj
  * @param {Object} obj
  * @param {String} key
  * @param {String} key
  * @param {*} val
  * @param {*} val
- * @param {Boolean} doNotObserve
  */
  */
 
 
-function defineReactive(obj, key, val, doNotObserve) {
+function defineReactive(obj, key, val) {
   var dep = new Dep();
   var dep = new Dep();
 
 
   var property = Object.getOwnPropertyDescriptor(obj, key);
   var property = Object.getOwnPropertyDescriptor(obj, key);
@@ -2209,11 +2226,7 @@ function defineReactive(obj, key, val, doNotObserve) {
   var getter = property && property.get;
   var getter = property && property.get;
   var setter = property && property.set;
   var setter = property && property.set;
 
 
-  // if doNotObserve is true, only use the child value observer
-  // if it already exists, and do not attempt to create it.
-  // this allows freezing a large object from the root and
-  // avoid unnecessary observation inside v-for fragments.
-  var childOb = doNotObserve ? isObject(val) && val.__ob__ : observe(val);
+  var childOb = observe(val);
   Object.defineProperty(obj, key, {
   Object.defineProperty(obj, key, {
     enumerable: true,
     enumerable: true,
     configurable: true,
     configurable: true,
@@ -2243,7 +2256,7 @@ function defineReactive(obj, key, val, doNotObserve) {
       } else {
       } else {
         val = newVal;
         val = newVal;
       }
       }
-      childOb = doNotObserve ? isObject(newVal) && newVal.__ob__ : observe(newVal);
+      childOb = observe(newVal);
       dep.notify();
       dep.notify();
     }
     }
   });
   });
@@ -4017,7 +4030,9 @@ var vFor = {
         // update data for track-by, object repeat &
         // update data for track-by, object repeat &
         // primitive values.
         // primitive values.
         if (trackByKey || convertedFromObject || primitive) {
         if (trackByKey || convertedFromObject || primitive) {
-          frag.scope[alias] = value;
+          withoutConversion(function () {
+            frag.scope[alias] = value;
+          });
         }
         }
       } else {
       } else {
         // new isntance
         // new isntance
@@ -4107,7 +4122,11 @@ var vFor = {
     // for two-way binding on alias
     // for two-way binding on alias
     scope.$forContext = this;
     scope.$forContext = this;
     // define scope properties
     // define scope properties
-    defineReactive(scope, alias, value, true /* do not observe */);
+    // important: define the scope alias without forced conversion
+    // so that frozen data structures remain non-reactive.
+    withoutConversion(function () {
+      defineReactive(scope, alias, value);
+    });
     defineReactive(scope, '$index', index);
     defineReactive(scope, '$index', index);
     if (key) {
     if (key) {
       defineReactive(scope, '$key', key);
       defineReactive(scope, '$key', key);
@@ -5705,7 +5724,9 @@ var component = {
 
 
   unbuild: function unbuild(defer) {
   unbuild: function unbuild(defer) {
     if (this.waitingFor) {
     if (this.waitingFor) {
-      this.waitingFor.$destroy();
+      if (!this.keepAlive) {
+        this.waitingFor.$destroy();
+      }
       this.waitingFor = null;
       this.waitingFor = null;
     }
     }
     var child = this.childVM;
     var child = this.childVM;
@@ -5999,15 +6020,7 @@ function initProp(vm, prop, value) {
     value = getPropDefaultValue(vm, prop.options);
     value = getPropDefaultValue(vm, prop.options);
   }
   }
   if (assertProp(prop, value)) {
   if (assertProp(prop, value)) {
-    var doNotObserve =
-    // if the passed down prop was already converted, then
-    // subsequent sets should also be converted, because the user
-    // may mutate the prop binding in the child component (#2549)
-    !(value && value.__ob__) && (
-    // otherwise we can skip observation for props that are either
-    // literal or points to a simple path (non-derived values)
-    !prop.dynamic || isSimplePath(prop.raw));
-    defineReactive(vm, key, value, doNotObserve);
+    defineReactive(vm, key, value);
   }
   }
 }
 }
 
 
@@ -6126,11 +6139,18 @@ var propDef = {
     var childKey = prop.path;
     var childKey = prop.path;
     var parentKey = prop.parentPath;
     var parentKey = prop.parentPath;
     var twoWay = prop.mode === bindingModes.TWO_WAY;
     var twoWay = prop.mode === bindingModes.TWO_WAY;
+    var isSimple = isSimplePath(parentKey);
 
 
     var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
     var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
       val = coerceProp(prop, val);
       val = coerceProp(prop, val);
       if (assertProp(prop, val)) {
       if (assertProp(prop, val)) {
-        child[childKey] = val;
+        if (isSimple) {
+          withoutConversion(function () {
+            child[childKey] = val;
+          });
+        } else {
+          child[childKey] = val;
+        }
       }
       }
     }, {
     }, {
       twoWay: twoWay,
       twoWay: twoWay,
@@ -6141,7 +6161,14 @@ var propDef = {
     });
     });
 
 
     // set the child initial value.
     // set the child initial value.
-    initProp(child, prop, parentWatcher.value);
+    var value = parentWatcher.value;
+    if (isSimple && value !== undefined) {
+      withoutConversion(function () {
+        initProp(child, prop, value);
+      });
+    } else {
+      initProp(child, prop, value);
+    }
 
 
     // setup two-way binding
     // setup two-way binding
     if (twoWay) {
     if (twoWay) {
@@ -7146,15 +7173,17 @@ function checkTerminalDirectives(el, attrs, options) {
     }
     }
   }
   }
 
 
-  var attr, name, value, matched, dirName, arg, def, termDef;
+  var attr, name, value, modifiers, matched, dirName, rawName, arg, def, termDef;
   for (var i = 0, j = attrs.length; i < j; i++) {
   for (var i = 0, j = attrs.length; i < j; i++) {
     attr = attrs[i];
     attr = attrs[i];
-    if (matched = attr.name.match(dirAttrRE)) {
+    modifiers = parseModifiers(attr.name);
+    name = attr.name.replace(modifierRE, '');
+    if (matched = name.match(dirAttrRE)) {
       def = resolveAsset(options, 'directives', matched[1]);
       def = resolveAsset(options, 'directives', matched[1]);
       if (def && def.terminal) {
       if (def && def.terminal) {
         if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
         if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
           termDef = def;
           termDef = def;
-          name = attr.name;
+          rawName = attr.name;
           value = attr.value;
           value = attr.value;
           dirName = matched[1];
           dirName = matched[1];
           arg = matched[2];
           arg = matched[2];
@@ -7164,7 +7193,7 @@ function checkTerminalDirectives(el, attrs, options) {
   }
   }
 
 
   if (termDef) {
   if (termDef) {
-    return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, name, arg);
+    return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, rawName, arg, modifiers);
   }
   }
 }
 }
 
 
@@ -7182,28 +7211,24 @@ skip.terminal = true;
  * @param {String} value
  * @param {String} value
  * @param {Object} options
  * @param {Object} options
  * @param {Object} def
  * @param {Object} def
- * @param {String} [attrName]
+ * @param {String} [rawName]
  * @param {String} [arg]
  * @param {String} [arg]
+ * @param {Object} [modifiers]
  * @return {Function} terminalLinkFn
  * @return {Function} terminalLinkFn
  */
  */
 
 
-function makeTerminalNodeLinkFn(el, dirName, value, options, def, attrName, arg) {
+function makeTerminalNodeLinkFn(el, dirName, value, options, def, rawName, arg, modifiers) {
   var parsed = parseDirective(value);
   var parsed = parseDirective(value);
   var descriptor = {
   var descriptor = {
     name: dirName,
     name: dirName,
+    arg: arg,
     expression: parsed.expression,
     expression: parsed.expression,
     filters: parsed.filters,
     filters: parsed.filters,
     raw: value,
     raw: value,
-    rawName: attrName,
+    attr: rawName,
+    modifiers: modifiers,
     def: def
     def: def
   };
   };
-  if (attrName) {
-    descriptor.rawName = attrName;
-    descriptor.modifiers = parseModifiers(attrName);
-  }
-  if (arg) {
-    descriptor.arg = arg.replace(modifierRE, '');
-  }
   // check ref for v-for and router-view
   // check ref for v-for and router-view
   if (dirName === 'for' || dirName === 'router-view') {
   if (dirName === 'for' || dirName === 'router-view') {
     descriptor.ref = findRef(el);
     descriptor.ref = findRef(el);
@@ -8133,7 +8158,7 @@ Directive.prototype._setupParams = function () {
   var i = params.length;
   var i = params.length;
   var key, val, mappedKey;
   var key, val, mappedKey;
   while (i--) {
   while (i--) {
-    key = params[i];
+    key = hyphenate(params[i]);
     mappedKey = camelize(key);
     mappedKey = camelize(key);
     val = getBindAttr(this.el, key);
     val = getBindAttr(this.el, key);
     if (val != null) {
     if (val != null) {
@@ -9781,7 +9806,7 @@ function installGlobalAPI (Vue) {
 
 
 installGlobalAPI(Vue);
 installGlobalAPI(Vue);
 
 
-Vue.version = '1.0.19';
+Vue.version = '1.0.20';
 
 
 // devtools global hook
 // devtools global hook
 /* istanbul ignore next */
 /* istanbul ignore next */

+ 65 - 40
dist/vue.js

@@ -1,5 +1,5 @@
 /*!
 /*!
- * Vue.js v1.0.19
+ * Vue.js v1.0.20
  * (c) 2016 Evan You
  * (c) 2016 Evan You
  * Released under the MIT License.
  * Released under the MIT License.
  */
  */
@@ -2046,6 +2046,24 @@ var transition = Object.freeze({
 
 
   var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
   var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
 
 
+  /**
+   * By default, when a reactive property is set, the new value is
+   * also converted to become reactive. However in certain cases, e.g.
+   * v-for scope alias and props, we don't want to force conversion
+   * because the value may be a nested value under a frozen data structure.
+   *
+   * So whenever we want to set a reactive property without forcing
+   * conversion on the new value, we wrap that call inside this function.
+   */
+
+  var shouldConvert = true;
+
+  function withoutConversion(fn) {
+    shouldConvert = false;
+    fn();
+    shouldConvert = true;
+  }
+
   /**
   /**
    * Observer class that are attached to each observed
    * Observer class that are attached to each observed
    * object. Once attached, the observer converts target
    * object. Once attached, the observer converts target
@@ -2183,7 +2201,7 @@ var transition = Object.freeze({
     var ob;
     var ob;
     if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
     if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
       ob = value.__ob__;
       ob = value.__ob__;
-    } else if ((isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
+    } else if (shouldConvert && (isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
       ob = new Observer(value);
       ob = new Observer(value);
     }
     }
     if (ob && vm) {
     if (ob && vm) {
@@ -2198,10 +2216,9 @@ var transition = Object.freeze({
    * @param {Object} obj
    * @param {Object} obj
    * @param {String} key
    * @param {String} key
    * @param {*} val
    * @param {*} val
-   * @param {Boolean} doNotObserve
    */
    */
 
 
-  function defineReactive(obj, key, val, doNotObserve) {
+  function defineReactive(obj, key, val) {
     var dep = new Dep();
     var dep = new Dep();
 
 
     var property = Object.getOwnPropertyDescriptor(obj, key);
     var property = Object.getOwnPropertyDescriptor(obj, key);
@@ -2213,11 +2230,7 @@ var transition = Object.freeze({
     var getter = property && property.get;
     var getter = property && property.get;
     var setter = property && property.set;
     var setter = property && property.set;
 
 
-    // if doNotObserve is true, only use the child value observer
-    // if it already exists, and do not attempt to create it.
-    // this allows freezing a large object from the root and
-    // avoid unnecessary observation inside v-for fragments.
-    var childOb = doNotObserve ? isObject(val) && val.__ob__ : observe(val);
+    var childOb = observe(val);
     Object.defineProperty(obj, key, {
     Object.defineProperty(obj, key, {
       enumerable: true,
       enumerable: true,
       configurable: true,
       configurable: true,
@@ -2247,7 +2260,7 @@ var transition = Object.freeze({
         } else {
         } else {
           val = newVal;
           val = newVal;
         }
         }
-        childOb = doNotObserve ? isObject(newVal) && newVal.__ob__ : observe(newVal);
+        childOb = observe(newVal);
         dep.notify();
         dep.notify();
       }
       }
     });
     });
@@ -4021,7 +4034,9 @@ var template = Object.freeze({
           // update data for track-by, object repeat &
           // update data for track-by, object repeat &
           // primitive values.
           // primitive values.
           if (trackByKey || convertedFromObject || primitive) {
           if (trackByKey || convertedFromObject || primitive) {
-            frag.scope[alias] = value;
+            withoutConversion(function () {
+              frag.scope[alias] = value;
+            });
           }
           }
         } else {
         } else {
           // new isntance
           // new isntance
@@ -4111,7 +4126,11 @@ var template = Object.freeze({
       // for two-way binding on alias
       // for two-way binding on alias
       scope.$forContext = this;
       scope.$forContext = this;
       // define scope properties
       // define scope properties
-      defineReactive(scope, alias, value, true /* do not observe */);
+      // important: define the scope alias without forced conversion
+      // so that frozen data structures remain non-reactive.
+      withoutConversion(function () {
+        defineReactive(scope, alias, value);
+      });
       defineReactive(scope, '$index', index);
       defineReactive(scope, '$index', index);
       if (key) {
       if (key) {
         defineReactive(scope, '$key', key);
         defineReactive(scope, '$key', key);
@@ -5709,7 +5728,9 @@ var template = Object.freeze({
 
 
     unbuild: function unbuild(defer) {
     unbuild: function unbuild(defer) {
       if (this.waitingFor) {
       if (this.waitingFor) {
-        this.waitingFor.$destroy();
+        if (!this.keepAlive) {
+          this.waitingFor.$destroy();
+        }
         this.waitingFor = null;
         this.waitingFor = null;
       }
       }
       var child = this.childVM;
       var child = this.childVM;
@@ -6003,15 +6024,7 @@ var template = Object.freeze({
       value = getPropDefaultValue(vm, prop.options);
       value = getPropDefaultValue(vm, prop.options);
     }
     }
     if (assertProp(prop, value)) {
     if (assertProp(prop, value)) {
-      var doNotObserve =
-      // if the passed down prop was already converted, then
-      // subsequent sets should also be converted, because the user
-      // may mutate the prop binding in the child component (#2549)
-      !(value && value.__ob__) && (
-      // otherwise we can skip observation for props that are either
-      // literal or points to a simple path (non-derived values)
-      !prop.dynamic || isSimplePath(prop.raw));
-      defineReactive(vm, key, value, doNotObserve);
+      defineReactive(vm, key, value);
     }
     }
   }
   }
 
 
@@ -6130,11 +6143,18 @@ var template = Object.freeze({
       var childKey = prop.path;
       var childKey = prop.path;
       var parentKey = prop.parentPath;
       var parentKey = prop.parentPath;
       var twoWay = prop.mode === bindingModes.TWO_WAY;
       var twoWay = prop.mode === bindingModes.TWO_WAY;
+      var isSimple = isSimplePath(parentKey);
 
 
       var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
       var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
         val = coerceProp(prop, val);
         val = coerceProp(prop, val);
         if (assertProp(prop, val)) {
         if (assertProp(prop, val)) {
-          child[childKey] = val;
+          if (isSimple) {
+            withoutConversion(function () {
+              child[childKey] = val;
+            });
+          } else {
+            child[childKey] = val;
+          }
         }
         }
       }, {
       }, {
         twoWay: twoWay,
         twoWay: twoWay,
@@ -6145,7 +6165,14 @@ var template = Object.freeze({
       });
       });
 
 
       // set the child initial value.
       // set the child initial value.
-      initProp(child, prop, parentWatcher.value);
+      var value = parentWatcher.value;
+      if (isSimple && value !== undefined) {
+        withoutConversion(function () {
+          initProp(child, prop, value);
+        });
+      } else {
+        initProp(child, prop, value);
+      }
 
 
       // setup two-way binding
       // setup two-way binding
       if (twoWay) {
       if (twoWay) {
@@ -7143,15 +7170,17 @@ var template = Object.freeze({
       }
       }
     }
     }
 
 
-    var attr, name, value, matched, dirName, arg, def, termDef;
+    var attr, name, value, modifiers, matched, dirName, rawName, arg, def, termDef;
     for (var i = 0, j = attrs.length; i < j; i++) {
     for (var i = 0, j = attrs.length; i < j; i++) {
       attr = attrs[i];
       attr = attrs[i];
-      if (matched = attr.name.match(dirAttrRE)) {
+      modifiers = parseModifiers(attr.name);
+      name = attr.name.replace(modifierRE, '');
+      if (matched = name.match(dirAttrRE)) {
         def = resolveAsset(options, 'directives', matched[1]);
         def = resolveAsset(options, 'directives', matched[1]);
         if (def && def.terminal) {
         if (def && def.terminal) {
           if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
           if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
             termDef = def;
             termDef = def;
-            name = attr.name;
+            rawName = attr.name;
             value = attr.value;
             value = attr.value;
             dirName = matched[1];
             dirName = matched[1];
             arg = matched[2];
             arg = matched[2];
@@ -7161,7 +7190,7 @@ var template = Object.freeze({
     }
     }
 
 
     if (termDef) {
     if (termDef) {
-      return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, name, arg);
+      return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, rawName, arg, modifiers);
     }
     }
   }
   }
 
 
@@ -7179,28 +7208,24 @@ var template = Object.freeze({
    * @param {String} value
    * @param {String} value
    * @param {Object} options
    * @param {Object} options
    * @param {Object} def
    * @param {Object} def
-   * @param {String} [attrName]
+   * @param {String} [rawName]
    * @param {String} [arg]
    * @param {String} [arg]
+   * @param {Object} [modifiers]
    * @return {Function} terminalLinkFn
    * @return {Function} terminalLinkFn
    */
    */
 
 
-  function makeTerminalNodeLinkFn(el, dirName, value, options, def, attrName, arg) {
+  function makeTerminalNodeLinkFn(el, dirName, value, options, def, rawName, arg, modifiers) {
     var parsed = parseDirective(value);
     var parsed = parseDirective(value);
     var descriptor = {
     var descriptor = {
       name: dirName,
       name: dirName,
+      arg: arg,
       expression: parsed.expression,
       expression: parsed.expression,
       filters: parsed.filters,
       filters: parsed.filters,
       raw: value,
       raw: value,
-      rawName: attrName,
+      attr: rawName,
+      modifiers: modifiers,
       def: def
       def: def
     };
     };
-    if (attrName) {
-      descriptor.rawName = attrName;
-      descriptor.modifiers = parseModifiers(attrName);
-    }
-    if (arg) {
-      descriptor.arg = arg.replace(modifierRE, '');
-    }
     // check ref for v-for and router-view
     // check ref for v-for and router-view
     if (dirName === 'for' || dirName === 'router-view') {
     if (dirName === 'for' || dirName === 'router-view') {
       descriptor.ref = findRef(el);
       descriptor.ref = findRef(el);
@@ -8130,7 +8155,7 @@ var template = Object.freeze({
     var i = params.length;
     var i = params.length;
     var key, val, mappedKey;
     var key, val, mappedKey;
     while (i--) {
     while (i--) {
-      key = params[i];
+      key = hyphenate(params[i]);
       mappedKey = camelize(key);
       mappedKey = camelize(key);
       val = getBindAttr(this.el, key);
       val = getBindAttr(this.el, key);
       if (val != null) {
       if (val != null) {
@@ -9778,7 +9803,7 @@ var template = Object.freeze({
 
 
   installGlobalAPI(Vue);
   installGlobalAPI(Vue);
 
 
-  Vue.version = '1.0.19';
+  Vue.version = '1.0.20';
 
 
   // devtools global hook
   // devtools global hook
   /* istanbul ignore next */
   /* istanbul ignore next */

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
dist/vue.min.js


+ 1 - 1
src/index.js

@@ -5,7 +5,7 @@ import config from './config'
 
 
 installGlobalAPI(Vue)
 installGlobalAPI(Vue)
 
 
-Vue.version = '1.0.19'
+Vue.version = '1.0.20'
 
 
 export default Vue
 export default Vue
 
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است