Evan You 9 лет назад
Родитель
Сommit
f5d4313d10

+ 128 - 114
dist/vue.common.js

@@ -355,18 +355,16 @@ var nextTick = function () {
 
   /* istanbul ignore else */
   if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
-    (function () {
-      var counter = 1;
-      var observer = new MutationObserver(nextTickHandler);
-      var textNode = document.createTextNode(String(counter));
-      observer.observe(textNode, {
-        characterData: true
-      });
-      timerFunc = function timerFunc() {
-        counter = (counter + 1) % 2;
-        textNode.data = String(counter);
-      };
-    })();
+    var counter = 1;
+    var observer = new MutationObserver(nextTickHandler);
+    var textNode = document.createTextNode(String(counter));
+    observer.observe(textNode, {
+      characterData: true
+    });
+    timerFunc = function timerFunc() {
+      counter = (counter + 1) % 2;
+      textNode.data = String(counter);
+    };
   } else {
     // webpack attempts to inject a shim for setImmediate
     // if it is used as a global, so we have to work around that to
@@ -418,7 +416,7 @@ var proxyHandlers = void 0;
 var initProxy = void 0;
 if (process.env.NODE_ENV !== 'production') {
   (function () {
-    var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require,__webpack_require__' // for Webpack/Browserify
+    var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require' // for Webpack/Browserify
     );
 
     hasProxy = typeof Proxy !== 'undefined' && Proxy.toString().match(/native code/);
@@ -426,11 +424,11 @@ if (process.env.NODE_ENV !== 'production') {
     proxyHandlers = {
       has: function has(target, key) {
         var has = key in target;
-        var isAllowedGlobal = allowedGlobals(key);
-        if (!has && !isAllowedGlobal) {
+        var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
+        if (!has && !isAllowed) {
           warn('Property or method "' + key + '" is not defined on the instance but ' + 'referenced during render. Make sure to declare reactive data ' + 'properties in the data option.', target);
         }
-        return !isAllowedGlobal;
+        return has || !isAllowed;
       }
     };
 
@@ -1217,6 +1215,9 @@ function stateMixin(Vue) {
   }
   Object.defineProperty(Vue.prototype, '$data', dataDef);
 
+  Vue.prototype.$set = set;
+  Vue.prototype.$delete = del;
+
   Vue.prototype.$watch = function (expOrFn, cb, options) {
     var vm = this;
     options = options || {};
@@ -1631,28 +1632,7 @@ function createComponent(Ctor, data, context, children, tag) {
 
   // functional component
   if (Ctor.options.functional) {
-    var _ret = function () {
-      var props = {};
-      var propOptions = Ctor.options.props;
-      if (propOptions) {
-        Object.keys(propOptions).forEach(function (key) {
-          props[key] = validateProp(key, propOptions, propsData);
-        });
-      }
-      return {
-        v: Ctor.options.render.call(null, context.$createElement, {
-          props: props,
-          data: data,
-          parent: context,
-          children: normalizeChildren(children),
-          slots: function slots() {
-            return resolveSlots(children);
-          }
-        })
-      };
-    }();
-
-    if (typeof _ret === "object") return _ret.v;
+    return createFunctionalComponent(Ctor, propsData, data, context, children);
   }
 
   // extract listeners, since these needs to be treated as
@@ -1676,6 +1656,25 @@ function createComponent(Ctor, data, context, children, tag) {
   return vnode;
 }
 
+function createFunctionalComponent(Ctor, propsData, data, context, children) {
+  var props = {};
+  var propOptions = Ctor.options.props;
+  if (propOptions) {
+    for (var key in propOptions) {
+      props[key] = validateProp(key, propOptions, propsData);
+    }
+  }
+  return Ctor.options.render.call(null, context.$createElement, {
+    props: props,
+    data: data,
+    parent: context,
+    children: normalizeChildren(children),
+    slots: function slots() {
+      return resolveSlots(children);
+    }
+  });
+}
+
 function createComponentInstanceForVnode(vnode, // we know it's MountedComponentVNode but flow doesn't
 parent // activeInstance in lifecycle state
 ) {
@@ -1742,7 +1741,7 @@ function resolveAsyncComponent(factory, cb) {
     // pool callbacks
     factory.pendingCallbacks.push(cb);
   } else {
-    var _ret2 = function () {
+    var _ret = function () {
       factory.requested = true;
       var cbs = factory.pendingCallbacks = [cb];
       var sync = true;
@@ -1773,7 +1772,7 @@ function resolveAsyncComponent(factory, cb) {
       };
     }();
 
-    if (typeof _ret2 === "object") return _ret2.v;
+    if (typeof _ret === "object") return _ret.v;
   }
 }
 
@@ -2245,7 +2244,7 @@ if (process.env.NODE_ENV !== 'production') {
 
     var formatLocation = function formatLocation(str) {
       if (str === 'anonymous component') {
-        str += ' - use the "name" option for better debugging messages.)';
+        str += ' - use the "name" option for better debugging messages.';
       }
       return '(found in ' + str + ')';
     };
@@ -2271,7 +2270,7 @@ if (process.env.NODE_ENV !== 'production') {
   };
 
   strats.name = function (parent, child, vm) {
-    if (vm) {
+    if (vm && child) {
       warn('options "name" can only be used as a component definition option, ' + 'not during instance creation.');
     }
     return defaultStrat(parent, child);
@@ -2879,7 +2878,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
   }
 });
 
-Vue.version = '2.0.0-rc.2';
+Vue.version = '2.0.0-rc.3';
 
 // attributes that should be using props for binding
 var mustUseProp = makeMap('value,selected,checked,muted');
@@ -3130,6 +3129,47 @@ var nodeOps = Object.freeze({
   setAttribute: setAttribute
 });
 
+var ref = {
+  create: function create(_, vnode) {
+    registerRef(vnode);
+  },
+  update: function update(oldVnode, vnode) {
+    if (oldVnode.data.ref !== vnode.data.ref) {
+      registerRef(oldVnode, true);
+      registerRef(vnode);
+    }
+  },
+  destroy: function destroy(vnode) {
+    registerRef(vnode, true);
+  }
+};
+
+function registerRef(vnode, isRemoval) {
+  var key = vnode.data.ref;
+  if (!key) return;
+
+  var vm = vnode.context;
+  var ref = vnode.child || vnode.elm;
+  var refs = vm.$refs;
+  if (isRemoval) {
+    if (Array.isArray(refs[key])) {
+      remove(refs[key], ref);
+    } else if (refs[key] === ref) {
+      refs[key] = undefined;
+    }
+  } else {
+    if (vnode.data.refInFor) {
+      if (Array.isArray(refs[key])) {
+        refs[key].push(ref);
+      } else {
+        refs[key] = [ref];
+      }
+    } else {
+      refs[key] = ref;
+    }
+  }
+}
+
 var emptyData = {};
 var emptyNode = new VNode('', emptyData, []);
 var hooks$1 = ['create', 'update', 'postpatch', 'remove', 'destroy'];
@@ -3263,6 +3303,10 @@ function createPatchFunction(backend) {
       invokeCreateHooks(vnode, insertedVnodeQueue);
       setScope(vnode);
     } else {
+      // empty component root.
+      // skip all element-related modules except for ref (#3455)
+      registerRef(vnode);
+      // make sure to invoke the insert hook
       insertedVnodeQueue.push(vnode);
     }
   }
@@ -3311,8 +3355,8 @@ function createPatchFunction(backend) {
       var ch = vnodes[startIdx];
       if (isDef(ch)) {
         if (isDef(ch.tag)) {
-          invokeDestroyHook(ch);
           removeAndInvokeRemoveHook(ch);
+          invokeDestroyHook(ch);
         } else {
           // Text node
           nodeOps.removeChild(parentElm, ch.elm);
@@ -3644,47 +3688,6 @@ function applyDirectives(oldVnode, vnode, hook) {
   }
 }
 
-var ref = {
-  create: function create(_, vnode) {
-    registerRef(vnode);
-  },
-  update: function update(oldVnode, vnode) {
-    if (oldVnode.data.ref !== vnode.data.ref) {
-      registerRef(oldVnode, true);
-      registerRef(vnode);
-    }
-  },
-  destroy: function destroy(vnode) {
-    registerRef(vnode, true);
-  }
-};
-
-function registerRef(vnode, isRemoval) {
-  var key = vnode.data.ref;
-  if (!key) return;
-
-  var vm = vnode.context;
-  var ref = vnode.child || vnode.elm;
-  var refs = vm.$refs;
-  if (isRemoval) {
-    if (Array.isArray(refs[key])) {
-      remove(refs[key], ref);
-    } else if (refs[key] === ref) {
-      refs[key] = undefined;
-    }
-  } else {
-    if (vnode.data.refInFor) {
-      if (Array.isArray(refs[key])) {
-        refs[key].push(ref);
-      } else {
-        refs[key] = [ref];
-      }
-    } else {
-      refs[key] = ref;
-    }
-  }
-}
-
 var baseModules = [ref, directives];
 
 function updateAttrs(oldVnode, vnode) {
@@ -4154,14 +4157,21 @@ function enter(vnode) {
 
   if (!vnode.data.show) {
     // remove pending leave element on enter by injecting an insert hook
-    mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
+    var hooks = vnode.data.hook || (vnode.data.hook = {});
+    hooks._transitionInsert = function () {
       var parent = el.parentNode;
-      var pendingNode = parent._pending && parent._pending[vnode.key];
+      var pendingNode = parent && parent._pending && parent._pending[vnode.key];
       if (pendingNode && pendingNode.tag === vnode.tag && pendingNode.elm._leaveCb) {
         pendingNode.elm._leaveCb();
       }
       enterHook && enterHook(el, cb);
-    });
+    };
+    if (!vnode.data.transitionInjected) {
+      vnode.data.transitionInjected = true;
+      mergeVNodeHook(hooks, 'insert', function () {
+        hooks._transitionInsert();
+      });
+    }
   }
 
   // start enter transition
@@ -4450,7 +4460,7 @@ var show = {
     if (value && transition && transition.appear && !isIE9) {
       enter(vnode);
     }
-    var originalDisplay = el.style.display;
+    var originalDisplay = el.style.display === 'none' ? '' : el.style.display;
     el.style.display = value ? originalDisplay : 'none';
     el.__vOriginalDisplay = originalDisplay;
   },
@@ -4594,6 +4604,14 @@ var Transition = {
     var oldRawChild = this._vnode;
     var oldChild = getRealChild(oldRawChild);
 
+    // mark v-show
+    // so that the transition module can hand over the control to the directive
+    if (child.data.directives && child.data.directives.some(function (d) {
+      return d.name === 'show';
+    })) {
+      child.data.show = true;
+    }
+
     if (oldChild && oldChild.data && oldChild.key !== child.key) {
       // replace old child transition data with fresh one
       // important for dynamic transitions!
@@ -4609,17 +4627,15 @@ var Transition = {
         });
         return placeholder(h, rawChild);
       } else if (mode === 'in-out') {
-        (function () {
-          var delayedLeave = void 0;
-          var performLeave = function performLeave() {
-            delayedLeave();
-          };
-          mergeVNodeHook(data, 'afterEnter', performLeave);
-          mergeVNodeHook(data, 'enterCancelled', performLeave);
-          mergeVNodeHook(oldData, 'delayLeave', function (leave) {
-            delayedLeave = leave;
-          });
-        })();
+        var delayedLeave;
+        var performLeave = function performLeave() {
+          delayedLeave();
+        };
+        mergeVNodeHook(data, 'afterEnter', performLeave);
+        mergeVNodeHook(data, 'enterCancelled', performLeave);
+        mergeVNodeHook(oldData, 'delayLeave', function (leave) {
+          delayedLeave = leave;
+        });
       }
     }
 
@@ -4718,20 +4734,18 @@ var TransitionGroup = {
 
     children.forEach(function (c) {
       if (c.data.moved) {
-        (function () {
-          var el = c.elm;
-          var s = el.style;
-          addTransitionClass(el, moveClass);
-          s.transform = s.WebkitTransform = s.transitionDuration = '';
-          el._moveDest = c.data.pos;
-          el.addEventListener(transitionEndEvent, el._moveCb = function cb(e) {
-            if (!e || /transform$/.test(e.propertyName)) {
-              el.removeEventListener(transitionEndEvent, cb);
-              el._moveCb = null;
-              removeTransitionClass(el, moveClass);
-            }
-          });
-        })();
+        var el = c.elm;
+        var s = el.style;
+        addTransitionClass(el, moveClass);
+        s.transform = s.WebkitTransform = s.transitionDuration = '';
+        el._moveDest = c.data.pos;
+        el.addEventListener(transitionEndEvent, el._moveCb = function cb(e) {
+          if (!e || /transform$/.test(e.propertyName)) {
+            el.removeEventListener(transitionEndEvent, cb);
+            el._moveCb = null;
+            removeTransitionClass(el, moveClass);
+          }
+        });
       }
     });
   },

+ 178 - 152
dist/vue.js

@@ -1,5 +1,5 @@
 /*!
- * Vue.js v2.0.0-rc.2
+ * Vue.js v2.0.0-rc.3
  * (c) 2014-2016 Evan You
  * Released under the MIT License.
  */
@@ -364,18 +364,16 @@
 
     /* istanbul ignore else */
     if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
-      (function () {
-        var counter = 1;
-        var observer = new MutationObserver(nextTickHandler);
-        var textNode = document.createTextNode(String(counter));
-        observer.observe(textNode, {
-          characterData: true
-        });
-        timerFunc = function timerFunc() {
-          counter = (counter + 1) % 2;
-          textNode.data = String(counter);
-        };
-      })();
+      var counter = 1;
+      var observer = new MutationObserver(nextTickHandler);
+      var textNode = document.createTextNode(String(counter));
+      observer.observe(textNode, {
+        characterData: true
+      });
+      timerFunc = function timerFunc() {
+        counter = (counter + 1) % 2;
+        textNode.data = String(counter);
+      };
     } else {
       // webpack attempts to inject a shim for setImmediate
       // if it is used as a global, so we have to work around that to
@@ -427,7 +425,7 @@
   var initProxy = void 0;
   if ("development" !== 'production') {
     (function () {
-      var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require,__webpack_require__' // for Webpack/Browserify
+      var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require' // for Webpack/Browserify
       );
 
       hasProxy = typeof Proxy !== 'undefined' && Proxy.toString().match(/native code/);
@@ -435,11 +433,11 @@
       proxyHandlers = {
         has: function has(target, key) {
           var has = key in target;
-          var isAllowedGlobal = allowedGlobals(key);
-          if (!has && !isAllowedGlobal) {
+          var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
+          if (!has && !isAllowed) {
             warn('Property or method "' + key + '" is not defined on the instance but ' + 'referenced during render. Make sure to declare reactive data ' + 'properties in the data option.', target);
           }
-          return !isAllowedGlobal;
+          return has || !isAllowed;
         }
       };
 
@@ -1224,6 +1222,9 @@
     }
     Object.defineProperty(Vue.prototype, '$data', dataDef);
 
+    Vue.prototype.$set = set;
+    Vue.prototype.$delete = del;
+
     Vue.prototype.$watch = function (expOrFn, cb, options) {
       var vm = this;
       options = options || {};
@@ -1638,28 +1639,7 @@
 
     // functional component
     if (Ctor.options.functional) {
-      var _ret = function () {
-        var props = {};
-        var propOptions = Ctor.options.props;
-        if (propOptions) {
-          Object.keys(propOptions).forEach(function (key) {
-            props[key] = validateProp(key, propOptions, propsData);
-          });
-        }
-        return {
-          v: Ctor.options.render.call(null, context.$createElement, {
-            props: props,
-            data: data,
-            parent: context,
-            children: normalizeChildren(children),
-            slots: function slots() {
-              return resolveSlots(children);
-            }
-          })
-        };
-      }();
-
-      if (typeof _ret === "object") return _ret.v;
+      return createFunctionalComponent(Ctor, propsData, data, context, children);
     }
 
     // extract listeners, since these needs to be treated as
@@ -1683,6 +1663,25 @@
     return vnode;
   }
 
+  function createFunctionalComponent(Ctor, propsData, data, context, children) {
+    var props = {};
+    var propOptions = Ctor.options.props;
+    if (propOptions) {
+      for (var key in propOptions) {
+        props[key] = validateProp(key, propOptions, propsData);
+      }
+    }
+    return Ctor.options.render.call(null, context.$createElement, {
+      props: props,
+      data: data,
+      parent: context,
+      children: normalizeChildren(children),
+      slots: function slots() {
+        return resolveSlots(children);
+      }
+    });
+  }
+
   function createComponentInstanceForVnode(vnode, // we know it's MountedComponentVNode but flow doesn't
   parent // activeInstance in lifecycle state
   ) {
@@ -1749,7 +1748,7 @@
       // pool callbacks
       factory.pendingCallbacks.push(cb);
     } else {
-      var _ret2 = function () {
+      var _ret = function () {
         factory.requested = true;
         var cbs = factory.pendingCallbacks = [cb];
         var sync = true;
@@ -1780,7 +1779,7 @@
         };
       }();
 
-      if (typeof _ret2 === "object") return _ret2.v;
+      if (typeof _ret === "object") return _ret.v;
     }
   }
 
@@ -2250,7 +2249,7 @@
 
       var formatLocation = function formatLocation(str) {
         if (str === 'anonymous component') {
-          str += ' - use the "name" option for better debugging messages.)';
+          str += ' - use the "name" option for better debugging messages.';
         }
         return '(found in ' + str + ')';
       };
@@ -2276,7 +2275,7 @@
     };
 
     strats.name = function (parent, child, vm) {
-      if (vm) {
+      if (vm && child) {
         warn('options "name" can only be used as a component definition option, ' + 'not during instance creation.');
       }
       return defaultStrat(parent, child);
@@ -2884,7 +2883,7 @@
     }
   });
 
-  Vue.version = '2.0.0-rc.2';
+  Vue.version = '2.0.0-rc.3';
 
   // attributes that should be using props for binding
   var mustUseProp = makeMap('value,selected,checked,muted');
@@ -3139,6 +3138,47 @@ var nodeOps = Object.freeze({
     setAttribute: setAttribute
   });
 
+  var ref = {
+    create: function create(_, vnode) {
+      registerRef(vnode);
+    },
+    update: function update(oldVnode, vnode) {
+      if (oldVnode.data.ref !== vnode.data.ref) {
+        registerRef(oldVnode, true);
+        registerRef(vnode);
+      }
+    },
+    destroy: function destroy(vnode) {
+      registerRef(vnode, true);
+    }
+  };
+
+  function registerRef(vnode, isRemoval) {
+    var key = vnode.data.ref;
+    if (!key) return;
+
+    var vm = vnode.context;
+    var ref = vnode.child || vnode.elm;
+    var refs = vm.$refs;
+    if (isRemoval) {
+      if (Array.isArray(refs[key])) {
+        remove(refs[key], ref);
+      } else if (refs[key] === ref) {
+        refs[key] = undefined;
+      }
+    } else {
+      if (vnode.data.refInFor) {
+        if (Array.isArray(refs[key])) {
+          refs[key].push(ref);
+        } else {
+          refs[key] = [ref];
+        }
+      } else {
+        refs[key] = ref;
+      }
+    }
+  }
+
   var emptyData = {};
   var emptyNode = new VNode('', emptyData, []);
   var hooks$1 = ['create', 'update', 'postpatch', 'remove', 'destroy'];
@@ -3272,6 +3312,10 @@ var nodeOps = Object.freeze({
         invokeCreateHooks(vnode, insertedVnodeQueue);
         setScope(vnode);
       } else {
+        // empty component root.
+        // skip all element-related modules except for ref (#3455)
+        registerRef(vnode);
+        // make sure to invoke the insert hook
         insertedVnodeQueue.push(vnode);
       }
     }
@@ -3320,8 +3364,8 @@ var nodeOps = Object.freeze({
         var ch = vnodes[startIdx];
         if (isDef(ch)) {
           if (isDef(ch.tag)) {
-            invokeDestroyHook(ch);
             removeAndInvokeRemoveHook(ch);
+            invokeDestroyHook(ch);
           } else {
             // Text node
             nodeOps.removeChild(parentElm, ch.elm);
@@ -3653,47 +3697,6 @@ var nodeOps = Object.freeze({
     }
   }
 
-  var ref = {
-    create: function create(_, vnode) {
-      registerRef(vnode);
-    },
-    update: function update(oldVnode, vnode) {
-      if (oldVnode.data.ref !== vnode.data.ref) {
-        registerRef(oldVnode, true);
-        registerRef(vnode);
-      }
-    },
-    destroy: function destroy(vnode) {
-      registerRef(vnode, true);
-    }
-  };
-
-  function registerRef(vnode, isRemoval) {
-    var key = vnode.data.ref;
-    if (!key) return;
-
-    var vm = vnode.context;
-    var ref = vnode.child || vnode.elm;
-    var refs = vm.$refs;
-    if (isRemoval) {
-      if (Array.isArray(refs[key])) {
-        remove(refs[key], ref);
-      } else if (refs[key] === ref) {
-        refs[key] = undefined;
-      }
-    } else {
-      if (vnode.data.refInFor) {
-        if (Array.isArray(refs[key])) {
-          refs[key].push(ref);
-        } else {
-          refs[key] = [ref];
-        }
-      } else {
-        refs[key] = ref;
-      }
-    }
-  }
-
   var baseModules = [ref, directives];
 
   function updateAttrs(oldVnode, vnode) {
@@ -4163,14 +4166,21 @@ var nodeOps = Object.freeze({
 
     if (!vnode.data.show) {
       // remove pending leave element on enter by injecting an insert hook
-      mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
+      var hooks = vnode.data.hook || (vnode.data.hook = {});
+      hooks._transitionInsert = function () {
         var parent = el.parentNode;
-        var pendingNode = parent._pending && parent._pending[vnode.key];
+        var pendingNode = parent && parent._pending && parent._pending[vnode.key];
         if (pendingNode && pendingNode.tag === vnode.tag && pendingNode.elm._leaveCb) {
           pendingNode.elm._leaveCb();
         }
         enterHook && enterHook(el, cb);
-      });
+      };
+      if (!vnode.data.transitionInjected) {
+        vnode.data.transitionInjected = true;
+        mergeVNodeHook(hooks, 'insert', function () {
+          hooks._transitionInsert();
+        });
+      }
     }
 
     // start enter transition
@@ -4459,7 +4469,7 @@ var nodeOps = Object.freeze({
       if (value && transition && transition.appear && !isIE9) {
         enter(vnode);
       }
-      var originalDisplay = el.style.display;
+      var originalDisplay = el.style.display === 'none' ? '' : el.style.display;
       el.style.display = value ? originalDisplay : 'none';
       el.__vOriginalDisplay = originalDisplay;
     },
@@ -4603,6 +4613,14 @@ var nodeOps = Object.freeze({
       var oldRawChild = this._vnode;
       var oldChild = getRealChild(oldRawChild);
 
+      // mark v-show
+      // so that the transition module can hand over the control to the directive
+      if (child.data.directives && child.data.directives.some(function (d) {
+        return d.name === 'show';
+      })) {
+        child.data.show = true;
+      }
+
       if (oldChild && oldChild.data && oldChild.key !== child.key) {
         // replace old child transition data with fresh one
         // important for dynamic transitions!
@@ -4618,17 +4636,15 @@ var nodeOps = Object.freeze({
           });
           return placeholder(h, rawChild);
         } else if (mode === 'in-out') {
-          (function () {
-            var delayedLeave = void 0;
-            var performLeave = function performLeave() {
-              delayedLeave();
-            };
-            mergeVNodeHook(data, 'afterEnter', performLeave);
-            mergeVNodeHook(data, 'enterCancelled', performLeave);
-            mergeVNodeHook(oldData, 'delayLeave', function (leave) {
-              delayedLeave = leave;
-            });
-          })();
+          var delayedLeave;
+          var performLeave = function performLeave() {
+            delayedLeave();
+          };
+          mergeVNodeHook(data, 'afterEnter', performLeave);
+          mergeVNodeHook(data, 'enterCancelled', performLeave);
+          mergeVNodeHook(oldData, 'delayLeave', function (leave) {
+            delayedLeave = leave;
+          });
         }
       }
 
@@ -4727,20 +4743,18 @@ var nodeOps = Object.freeze({
 
       children.forEach(function (c) {
         if (c.data.moved) {
-          (function () {
-            var el = c.elm;
-            var s = el.style;
-            addTransitionClass(el, moveClass);
-            s.transform = s.WebkitTransform = s.transitionDuration = '';
-            el._moveDest = c.data.pos;
-            el.addEventListener(transitionEndEvent, el._moveCb = function cb(e) {
-              if (!e || /transform$/.test(e.propertyName)) {
-                el.removeEventListener(transitionEndEvent, cb);
-                el._moveCb = null;
-                removeTransitionClass(el, moveClass);
-              }
-            });
-          })();
+          var el = c.elm;
+          var s = el.style;
+          addTransitionClass(el, moveClass);
+          s.transform = s.WebkitTransform = s.transitionDuration = '';
+          el._moveDest = c.data.pos;
+          el.addEventListener(transitionEndEvent, el._moveCb = function cb(e) {
+            if (!e || /transform$/.test(e.propertyName)) {
+              el.removeEventListener(transitionEndEvent, cb);
+              el._moveCb = null;
+              removeTransitionClass(el, moveClass);
+            }
+          });
         }
       });
     },
@@ -4921,24 +4935,22 @@ var nodeOps = Object.freeze({
           options.chars(text);
         }
       } else {
-        (function () {
-          var stackedTag = lastTag.toLowerCase();
-          var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
-          var endTagLength = 0;
-          var rest = html.replace(reStackedTag, function (all, text, endTag) {
-            endTagLength = endTag.length;
-            if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
-              text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
-            }
-            if (options.chars) {
-              options.chars(text);
-            }
-            return '';
-          });
-          index += html.length - rest.length;
-          html = rest;
-          parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
-        })();
+        var stackedTag = lastTag.toLowerCase();
+        var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
+        var endTagLength = 0;
+        var rest = html.replace(reStackedTag, function (all, text, endTag) {
+          endTagLength = endTag.length;
+          if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
+            text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
+          }
+          if (options.chars) {
+            options.chars(text);
+          }
+          return '';
+        });
+        index += html.length - rest.length;
+        html = rest;
+        parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
       }
 
       if (html === last) {
@@ -5226,7 +5238,7 @@ var nodeOps = Object.freeze({
     }
   }
 
-  function addHandler(el, name, value, modifiers) {
+  function addHandler(el, name, value, modifiers, important) {
     // check capture modifier
     if (modifiers && modifiers.capture) {
       delete modifiers.capture;
@@ -5243,9 +5255,9 @@ var nodeOps = Object.freeze({
     var handlers = events[name];
     /* istanbul ignore if */
     if (Array.isArray(handlers)) {
-      handlers.push(newHandler);
+      important ? handlers.unshift(newHandler) : handlers.push(newHandler);
     } else if (handlers) {
-      events[name] = [handlers, newHandler];
+      events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
     } else {
       events[name] = newHandler;
     }
@@ -5834,19 +5846,25 @@ var nodeOps = Object.freeze({
     } else if (!handler.modifiers) {
       return simplePathRE.test(handler.value) ? handler.value : 'function($event){' + handler.value + '}';
     } else {
-      var code = 'function($event){';
+      var code = '';
+      var keys = [];
       for (var key in handler.modifiers) {
-        code += modifierCode[key] || genKeyFilter(key);
+        if (modifierCode[key]) {
+          code += modifierCode[key];
+        } else {
+          keys.push(key);
+        }
+      }
+      if (keys.length) {
+        code = genKeyFilter(keys) + code;
       }
       var handlerCode = simplePathRE.test(handler.value) ? handler.value + '($event)' : handler.value;
-      return code + handlerCode + '}';
+      return 'function($event){' + code + handlerCode + '}';
     }
   }
 
-  function genKeyFilter(key) {
-    var code = parseInt(key, 10) || // number keyCode
-    keyCodes[key] || // built-in alias
-    '_k(' + JSON.stringify(key) + ')'; // custom alias
+  function genKeyFilter(keys) {
+    var code = keys.length === 1 ? normalizeKeyCode(keys[0]) : Array.prototype.concat.apply([], keys.map(normalizeKeyCode));
     if (Array.isArray(code)) {
       return 'if(' + code.map(function (c) {
         return '$event.keyCode!==' + c;
@@ -5856,6 +5874,13 @@ var nodeOps = Object.freeze({
     }
   }
 
+  function normalizeKeyCode(key) {
+    return parseInt(key, 10) || // number keyCode
+    keyCodes[key] || // built-in alias
+    '_k(' + JSON.stringify(key) + ')' // custom alias
+    ;
+  }
+
   function bind$1(el, dir) {
     addHook(el, 'construct', '_b(n1,' + dir.value + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ')');
   }
@@ -5978,11 +6003,6 @@ var nodeOps = Object.freeze({
     for (var i = 0; i < dataGenFns.length; i++) {
       data += dataGenFns[i](el);
     }
-    // v-show, used to avoid transition being applied
-    // since v-show takes it over
-    if (el.attrsMap['v-show']) {
-      data += 'show:true,';
-    }
     // attributes
     if (el.attrs) {
       data += 'attrs:{' + genProps(el.attrs) + '},';
@@ -6256,7 +6276,7 @@ var nodeOps = Object.freeze({
     var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
     var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
     addProp(el, 'checked', 'Array.isArray(' + value + ')' + ('?(' + value + ').indexOf(' + valueBinding + ')>-1') + (':(' + value + ')===(' + trueValueBinding + ')'));
-    addHandler(el, 'change', 'var $$a=' + value + ',' + '$$el=$event.target,' + ('$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');') + 'if(Array.isArray($$a)){' + ('var $$v=' + valueBinding + ',') + '$$i=$$a.indexOf($$v);' + ('if($$c){$$i<0&&(' + value + '=$$a.concat($$v))}') + ('else{$$i>-1&&(' + value + '=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}') + ('}else{' + value + '=$$c}'));
+    addHandler(el, 'change', 'var $$a=' + value + ',' + '$$el=$event.target,' + ('$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');') + 'if(Array.isArray($$a)){' + ('var $$v=' + valueBinding + ',') + '$$i=$$a.indexOf($$v);' + ('if($$c){$$i<0&&(' + value + '=$$a.concat($$v))}') + ('else{$$i>-1&&(' + value + '=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}') + ('}else{' + value + '=$$c}'), null, true);
   }
 
   function genRadioModel(el, value) {
@@ -6265,7 +6285,7 @@ var nodeOps = Object.freeze({
     }
     var valueBinding = getBindingAttr(el, 'value');
     addProp(el, 'checked', '(' + value + ')===(' + valueBinding + ')');
-    addHandler(el, 'change', value + '=' + valueBinding);
+    addHandler(el, 'change', value + '=' + valueBinding, null, true);
   }
 
   function genDefaultModel(el, value, modifiers) {
@@ -6296,7 +6316,7 @@ var nodeOps = Object.freeze({
       code = 'if($event.target.composing)return;' + code;
     }
     addProp(el, 'value', isNative ? '_s(' + value + ')' : '(' + value + ')');
-    addHandler(el, event, code);
+    addHandler(el, event, code, null, true);
     if (needCompositionGuard) {
       // need runtime directive code to help with composition events
       return true;
@@ -6308,7 +6328,7 @@ var nodeOps = Object.freeze({
       el.children.some(checkOptionWarning);
     }
     var code = value + '=Array.prototype.filter' + '.call($event.target.options,function(o){return o.selected})' + '.map(function(o){return "_value" in o ? o._value : o.value})' + (el.attrsMap.multiple == null ? '[0]' : '');
-    addHandler(el, 'change', code);
+    addHandler(el, 'change', code, null, true);
     // need runtime to help with possible dynamically generated options
     return true;
   }
@@ -6410,6 +6430,12 @@ var nodeOps = Object.freeze({
   var mount = Vue.prototype.$mount;
   Vue.prototype.$mount = function (el, hydrating) {
     el = el && query(el);
+
+    if (el === document.body || el === document.documentElement) {
+      "development" !== 'production' && warn('Do not mount Vue to <html> or <body> - mount to normal elements instead.');
+      return this;
+    }
+
     var options = this.$options;
     // resolve template/el and convert to render function
     if (!options.render) {

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/vue.min.js


+ 103 - 85
packages/vue-server-renderer/build.js

@@ -64,12 +64,6 @@ var possibleConstructorReturn = function (self, call) {
   return call && (typeof call === "object" || typeof call === "function") ? call : self;
 };
 
-/**
- * Original RenderStream implmentation by Sasha Aickin (@aickin)
- * Licensed under the Apache License, Version 2.0
- * Modified by Evan You (@yyx990803)
- */
-
 var RenderStream = function (_stream$Readable) {
   inherits(RenderStream, _stream$Readable);
 
@@ -436,7 +430,7 @@ if (process.env.NODE_ENV !== 'production') {
 
     var formatLocation = function formatLocation(str) {
       if (str === 'anonymous component') {
-        str += ' - use the "name" option for better debugging messages.)';
+        str += ' - use the "name" option for better debugging messages.';
       }
       return '(found in ' + str + ')';
     };
@@ -533,18 +527,16 @@ var nextTick = function () {
 
   /* istanbul ignore else */
   if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
-    (function () {
-      var counter = 1;
-      var observer = new MutationObserver(nextTickHandler);
-      var textNode = document.createTextNode(String(counter));
-      observer.observe(textNode, {
-        characterData: true
-      });
-      timerFunc = function timerFunc() {
-        counter = (counter + 1) % 2;
-        textNode.data = String(counter);
-      };
-    })();
+    var counter = 1;
+    var observer = new MutationObserver(nextTickHandler);
+    var textNode = document.createTextNode(String(counter));
+    observer.observe(textNode, {
+      characterData: true
+    });
+    timerFunc = function timerFunc() {
+      counter = (counter + 1) % 2;
+      textNode.data = String(counter);
+    };
   } else {
     // webpack attempts to inject a shim for setImmediate
     // if it is used as a global, so we have to work around that to
@@ -596,7 +588,7 @@ var proxyHandlers = void 0;
 var initProxy = void 0;
 if (process.env.NODE_ENV !== 'production') {
   (function () {
-    var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require,__webpack_require__' // for Webpack/Browserify
+    var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require' // for Webpack/Browserify
     );
 
     hasProxy = typeof Proxy !== 'undefined' && Proxy.toString().match(/native code/);
@@ -604,11 +596,11 @@ if (process.env.NODE_ENV !== 'production') {
     proxyHandlers = {
       has: function has(target, key) {
         var has = key in target;
-        var isAllowedGlobal = allowedGlobals(key);
-        if (!has && !isAllowedGlobal) {
+        var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
+        if (!has && !isAllowed) {
           warn('Property or method "' + key + '" is not defined on the instance but ' + 'referenced during render. Make sure to declare reactive data ' + 'properties in the data option.', target);
         }
-        return !isAllowedGlobal;
+        return has || !isAllowed;
       }
     };
 
@@ -1223,6 +1215,25 @@ function set$1(obj, key, val) {
   return val;
 }
 
+/**
+ * Delete a property and trigger change if necessary.
+ */
+function del(obj, key) {
+  var ob = obj.__ob__;
+  if (obj._isVue || ob && ob.vmCount) {
+    process.env.NODE_ENV !== 'production' && warn('Avoid deleting properties on a Vue instance or its root $data ' + '- just set it to null.');
+    return;
+  }
+  if (!hasOwn(obj, key)) {
+    return;
+  }
+  delete obj[key];
+  if (!ob) {
+    return;
+  }
+  ob.dep.notify();
+}
+
 function initState(vm) {
   vm._watchers = [];
   initProps(vm);
@@ -1376,6 +1387,9 @@ function stateMixin(Vue) {
   }
   Object.defineProperty(Vue.prototype, '$data', dataDef);
 
+  Vue.prototype.$set = set$1;
+  Vue.prototype.$delete = del;
+
   Vue.prototype.$watch = function (expOrFn, cb, options) {
     var vm = this;
     options = options || {};
@@ -1772,28 +1786,7 @@ function createComponent(Ctor, data, context, children, tag) {
 
   // functional component
   if (Ctor.options.functional) {
-    var _ret = function () {
-      var props = {};
-      var propOptions = Ctor.options.props;
-      if (propOptions) {
-        Object.keys(propOptions).forEach(function (key) {
-          props[key] = validateProp(key, propOptions, propsData);
-        });
-      }
-      return {
-        v: Ctor.options.render.call(null, context.$createElement, {
-          props: props,
-          data: data,
-          parent: context,
-          children: normalizeChildren(children),
-          slots: function slots() {
-            return resolveSlots(children);
-          }
-        })
-      };
-    }();
-
-    if (typeof _ret === "object") return _ret.v;
+    return createFunctionalComponent(Ctor, propsData, data, context, children);
   }
 
   // extract listeners, since these needs to be treated as
@@ -1817,6 +1810,25 @@ function createComponent(Ctor, data, context, children, tag) {
   return vnode;
 }
 
+function createFunctionalComponent(Ctor, propsData, data, context, children) {
+  var props = {};
+  var propOptions = Ctor.options.props;
+  if (propOptions) {
+    for (var key in propOptions) {
+      props[key] = validateProp(key, propOptions, propsData);
+    }
+  }
+  return Ctor.options.render.call(null, context.$createElement, {
+    props: props,
+    data: data,
+    parent: context,
+    children: normalizeChildren(children),
+    slots: function slots() {
+      return resolveSlots(children);
+    }
+  });
+}
+
 function createComponentInstanceForVnode(vnode, // we know it's MountedComponentVNode but flow doesn't
 parent // activeInstance in lifecycle state
 ) {
@@ -1883,7 +1895,7 @@ function resolveAsyncComponent(factory, cb) {
     // pool callbacks
     factory.pendingCallbacks.push(cb);
   } else {
-    var _ret2 = function () {
+    var _ret = function () {
       factory.requested = true;
       var cbs = factory.pendingCallbacks = [cb];
       var sync = true;
@@ -1914,7 +1926,7 @@ function resolveAsyncComponent(factory, cb) {
       };
     }();
 
-    if (typeof _ret2 === "object") return _ret2.v;
+    if (typeof _ret === "object") return _ret.v;
   }
 }
 
@@ -2382,7 +2394,7 @@ if (process.env.NODE_ENV !== 'production') {
   };
 
   strats.name = function (parent, child, vm) {
-    if (vm) {
+    if (vm && child) {
       warn('options "name" can only be used as a component definition option, ' + 'not during instance creation.');
     }
     return defaultStrat(parent, child);
@@ -3022,24 +3034,22 @@ function parseHTML(html, options) {
         options.chars(text);
       }
     } else {
-      (function () {
-        var stackedTag = lastTag.toLowerCase();
-        var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
-        var endTagLength = 0;
-        var rest = html.replace(reStackedTag, function (all, text, endTag) {
-          endTagLength = endTag.length;
-          if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
-            text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
-          }
-          if (options.chars) {
-            options.chars(text);
-          }
-          return '';
-        });
-        index += html.length - rest.length;
-        html = rest;
-        parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
-      })();
+      var stackedTag = lastTag.toLowerCase();
+      var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
+      var endTagLength = 0;
+      var rest = html.replace(reStackedTag, function (all, text, endTag) {
+        endTagLength = endTag.length;
+        if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
+          text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
+        }
+        if (options.chars) {
+          options.chars(text);
+        }
+        return '';
+      });
+      index += html.length - rest.length;
+      html = rest;
+      parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
     }
 
     if (html === last) {
@@ -3327,7 +3337,7 @@ function addHook(el, name, code) {
   }
 }
 
-function addHandler(el, name, value, modifiers) {
+function addHandler(el, name, value, modifiers, important) {
   // check capture modifier
   if (modifiers && modifiers.capture) {
     delete modifiers.capture;
@@ -3344,9 +3354,9 @@ function addHandler(el, name, value, modifiers) {
   var handlers = events[name];
   /* istanbul ignore if */
   if (Array.isArray(handlers)) {
-    handlers.push(newHandler);
+    important ? handlers.unshift(newHandler) : handlers.push(newHandler);
   } else if (handlers) {
-    events[name] = [handlers, newHandler];
+    events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
   } else {
     events[name] = newHandler;
   }
@@ -3935,19 +3945,25 @@ function genHandler(handler) {
   } else if (!handler.modifiers) {
     return simplePathRE.test(handler.value) ? handler.value : 'function($event){' + handler.value + '}';
   } else {
-    var code = 'function($event){';
+    var code = '';
+    var keys = [];
     for (var key in handler.modifiers) {
-      code += modifierCode[key] || genKeyFilter(key);
+      if (modifierCode[key]) {
+        code += modifierCode[key];
+      } else {
+        keys.push(key);
+      }
+    }
+    if (keys.length) {
+      code = genKeyFilter(keys) + code;
     }
     var handlerCode = simplePathRE.test(handler.value) ? handler.value + '($event)' : handler.value;
-    return code + handlerCode + '}';
+    return 'function($event){' + code + handlerCode + '}';
   }
 }
 
-function genKeyFilter(key) {
-  var code = parseInt(key, 10) || // number keyCode
-  keyCodes[key] || // built-in alias
-  '_k(' + JSON.stringify(key) + ')'; // custom alias
+function genKeyFilter(keys) {
+  var code = keys.length === 1 ? normalizeKeyCode(keys[0]) : Array.prototype.concat.apply([], keys.map(normalizeKeyCode));
   if (Array.isArray(code)) {
     return 'if(' + code.map(function (c) {
       return '$event.keyCode!==' + c;
@@ -3957,6 +3973,13 @@ function genKeyFilter(key) {
   }
 }
 
+function normalizeKeyCode(key) {
+  return parseInt(key, 10) || // number keyCode
+  keyCodes[key] || // built-in alias
+  '_k(' + JSON.stringify(key) + ')' // custom alias
+  ;
+}
+
 function bind$1(el, dir) {
   addHook(el, 'construct', '_b(n1,' + dir.value + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ')');
 }
@@ -4079,11 +4102,6 @@ function genData(el) {
   for (var i = 0; i < dataGenFns.length; i++) {
     data += dataGenFns[i](el);
   }
-  // v-show, used to avoid transition being applied
-  // since v-show takes it over
-  if (el.attrsMap['v-show']) {
-    data += 'show:true,';
-  }
   // attributes
   if (el.attrs) {
     data += 'attrs:{' + genProps(el.attrs) + '},';
@@ -4357,7 +4375,7 @@ function genCheckboxModel(el, value) {
   var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
   var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
   addProp(el, 'checked', 'Array.isArray(' + value + ')' + ('?(' + value + ').indexOf(' + valueBinding + ')>-1') + (':(' + value + ')===(' + trueValueBinding + ')'));
-  addHandler(el, 'change', 'var $$a=' + value + ',' + '$$el=$event.target,' + ('$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');') + 'if(Array.isArray($$a)){' + ('var $$v=' + valueBinding + ',') + '$$i=$$a.indexOf($$v);' + ('if($$c){$$i<0&&(' + value + '=$$a.concat($$v))}') + ('else{$$i>-1&&(' + value + '=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}') + ('}else{' + value + '=$$c}'));
+  addHandler(el, 'change', 'var $$a=' + value + ',' + '$$el=$event.target,' + ('$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');') + 'if(Array.isArray($$a)){' + ('var $$v=' + valueBinding + ',') + '$$i=$$a.indexOf($$v);' + ('if($$c){$$i<0&&(' + value + '=$$a.concat($$v))}') + ('else{$$i>-1&&(' + value + '=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}') + ('}else{' + value + '=$$c}'), null, true);
 }
 
 function genRadioModel(el, value) {
@@ -4366,7 +4384,7 @@ function genRadioModel(el, value) {
   }
   var valueBinding = getBindingAttr(el, 'value');
   addProp(el, 'checked', '(' + value + ')===(' + valueBinding + ')');
-  addHandler(el, 'change', value + '=' + valueBinding);
+  addHandler(el, 'change', value + '=' + valueBinding, null, true);
 }
 
 function genDefaultModel(el, value, modifiers) {
@@ -4397,7 +4415,7 @@ function genDefaultModel(el, value, modifiers) {
     code = 'if($event.target.composing)return;' + code;
   }
   addProp(el, 'value', isNative ? '_s(' + value + ')' : '(' + value + ')');
-  addHandler(el, event, code);
+  addHandler(el, event, code, null, true);
   if (needCompositionGuard) {
     // need runtime directive code to help with composition events
     return true;
@@ -4409,7 +4427,7 @@ function genSelect(el, value) {
     el.children.some(checkOptionWarning);
   }
   var code = value + '=Array.prototype.filter' + '.call($event.target.options,function(o){return o.selected})' + '.map(function(o){return "_value" in o ? o._value : o.value})' + (el.attrsMap.multiple == null ? '[0]' : '');
-  addHandler(el, 'change', code);
+  addHandler(el, 'change', code, null, true);
   // need runtime to help with possible dynamically generated options
   return true;
 }

+ 1 - 1
packages/vue-server-renderer/package.json

@@ -1,6 +1,6 @@
 {
   "name": "vue-server-renderer",
-  "version": "2.0.0-rc.2",
+  "version": "2.0.0-rc.3",
   "description": "server renderer for Vue 2.0",
   "main": "index.js",
   "repository": {

+ 105 - 80
packages/vue-template-compiler/build.js

@@ -295,7 +295,7 @@ if (process.env.NODE_ENV !== 'production') {
 
     var formatLocation = function formatLocation(str) {
       if (str === 'anonymous component') {
-        str += ' - use the "name" option for better debugging messages.)';
+        str += ' - use the "name" option for better debugging messages.';
       }
       return '(found in ' + str + ')';
     };
@@ -392,18 +392,16 @@ var nextTick = function () {
 
   /* istanbul ignore else */
   if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
-    (function () {
-      var counter = 1;
-      var observer = new MutationObserver(nextTickHandler);
-      var textNode = document.createTextNode(String(counter));
-      observer.observe(textNode, {
-        characterData: true
-      });
-      timerFunc = function timerFunc() {
-        counter = (counter + 1) % 2;
-        textNode.data = String(counter);
-      };
-    })();
+    var counter = 1;
+    var observer = new MutationObserver(nextTickHandler);
+    var textNode = document.createTextNode(String(counter));
+    observer.observe(textNode, {
+      characterData: true
+    });
+    timerFunc = function timerFunc() {
+      counter = (counter + 1) % 2;
+      textNode.data = String(counter);
+    };
   } else {
     // webpack attempts to inject a shim for setImmediate
     // if it is used as a global, so we have to work around that to
@@ -455,7 +453,7 @@ var proxyHandlers = void 0;
 var initProxy = void 0;
 if (process.env.NODE_ENV !== 'production') {
   (function () {
-    var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require,__webpack_require__' // for Webpack/Browserify
+    var allowedGlobals = makeMap('Infinity,undefined,NaN,isFinite,isNaN,' + 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 'require' // for Webpack/Browserify
     );
 
     hasProxy = typeof Proxy !== 'undefined' && Proxy.toString().match(/native code/);
@@ -463,11 +461,11 @@ if (process.env.NODE_ENV !== 'production') {
     proxyHandlers = {
       has: function has(target, key) {
         var has = key in target;
-        var isAllowedGlobal = allowedGlobals(key);
-        if (!has && !isAllowedGlobal) {
+        var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
+        if (!has && !isAllowed) {
           warn('Property or method "' + key + '" is not defined on the instance but ' + 'referenced during render. Make sure to declare reactive data ' + 'properties in the data option.', target);
         }
-        return !isAllowedGlobal;
+        return has || !isAllowed;
       }
     };
 
@@ -1082,6 +1080,25 @@ function set(obj, key, val) {
   return val;
 }
 
+/**
+ * Delete a property and trigger change if necessary.
+ */
+function del(obj, key) {
+  var ob = obj.__ob__;
+  if (obj._isVue || ob && ob.vmCount) {
+    process.env.NODE_ENV !== 'production' && warn('Avoid deleting properties on a Vue instance or its root $data ' + '- just set it to null.');
+    return;
+  }
+  if (!hasOwn(obj, key)) {
+    return;
+  }
+  delete obj[key];
+  if (!ob) {
+    return;
+  }
+  ob.dep.notify();
+}
+
 function initState(vm) {
   vm._watchers = [];
   initProps(vm);
@@ -1235,6 +1252,9 @@ function stateMixin(Vue) {
   }
   Object.defineProperty(Vue.prototype, '$data', dataDef);
 
+  Vue.prototype.$set = set;
+  Vue.prototype.$delete = del;
+
   Vue.prototype.$watch = function (expOrFn, cb, options) {
     var vm = this;
     options = options || {};
@@ -1631,28 +1651,7 @@ function createComponent(Ctor, data, context, children, tag) {
 
   // functional component
   if (Ctor.options.functional) {
-    var _ret = function () {
-      var props = {};
-      var propOptions = Ctor.options.props;
-      if (propOptions) {
-        Object.keys(propOptions).forEach(function (key) {
-          props[key] = validateProp(key, propOptions, propsData);
-        });
-      }
-      return {
-        v: Ctor.options.render.call(null, context.$createElement, {
-          props: props,
-          data: data,
-          parent: context,
-          children: normalizeChildren(children),
-          slots: function slots() {
-            return resolveSlots(children);
-          }
-        })
-      };
-    }();
-
-    if (typeof _ret === "object") return _ret.v;
+    return createFunctionalComponent(Ctor, propsData, data, context, children);
   }
 
   // extract listeners, since these needs to be treated as
@@ -1676,6 +1675,25 @@ function createComponent(Ctor, data, context, children, tag) {
   return vnode;
 }
 
+function createFunctionalComponent(Ctor, propsData, data, context, children) {
+  var props = {};
+  var propOptions = Ctor.options.props;
+  if (propOptions) {
+    for (var key in propOptions) {
+      props[key] = validateProp(key, propOptions, propsData);
+    }
+  }
+  return Ctor.options.render.call(null, context.$createElement, {
+    props: props,
+    data: data,
+    parent: context,
+    children: normalizeChildren(children),
+    slots: function slots() {
+      return resolveSlots(children);
+    }
+  });
+}
+
 function createComponentInstanceForVnode(vnode, // we know it's MountedComponentVNode but flow doesn't
 parent // activeInstance in lifecycle state
 ) {
@@ -1742,7 +1760,7 @@ function resolveAsyncComponent(factory, cb) {
     // pool callbacks
     factory.pendingCallbacks.push(cb);
   } else {
-    var _ret2 = function () {
+    var _ret = function () {
       factory.requested = true;
       var cbs = factory.pendingCallbacks = [cb];
       var sync = true;
@@ -1773,7 +1791,7 @@ function resolveAsyncComponent(factory, cb) {
       };
     }();
 
-    if (typeof _ret2 === "object") return _ret2.v;
+    if (typeof _ret === "object") return _ret.v;
   }
 }
 
@@ -2241,7 +2259,7 @@ if (process.env.NODE_ENV !== 'production') {
   };
 
   strats.name = function (parent, child, vm) {
-    if (vm) {
+    if (vm && child) {
       warn('options "name" can only be used as a component definition option, ' + 'not during instance creation.');
     }
     return defaultStrat(parent, child);
@@ -2798,24 +2816,22 @@ function parseHTML(html, options) {
         options.chars(text);
       }
     } else {
-      (function () {
-        var stackedTag = lastTag.toLowerCase();
-        var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
-        var endTagLength = 0;
-        var rest = html.replace(reStackedTag, function (all, text, endTag) {
-          endTagLength = endTag.length;
-          if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
-            text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
-          }
-          if (options.chars) {
-            options.chars(text);
-          }
-          return '';
-        });
-        index += html.length - rest.length;
-        html = rest;
-        parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
-      })();
+      var stackedTag = lastTag.toLowerCase();
+      var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
+      var endTagLength = 0;
+      var rest = html.replace(reStackedTag, function (all, text, endTag) {
+        endTagLength = endTag.length;
+        if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
+          text = text.replace(/<!--([\s\S]*?)-->/g, '$1').replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1');
+        }
+        if (options.chars) {
+          options.chars(text);
+        }
+        return '';
+      });
+      index += html.length - rest.length;
+      html = rest;
+      parseEndTag('</' + stackedTag + '>', stackedTag, index - endTagLength, index);
     }
 
     if (html === last) {
@@ -3103,7 +3119,7 @@ function addHook(el, name, code) {
   }
 }
 
-function addHandler(el, name, value, modifiers) {
+function addHandler(el, name, value, modifiers, important) {
   // check capture modifier
   if (modifiers && modifiers.capture) {
     delete modifiers.capture;
@@ -3120,9 +3136,9 @@ function addHandler(el, name, value, modifiers) {
   var handlers = events[name];
   /* istanbul ignore if */
   if (Array.isArray(handlers)) {
-    handlers.push(newHandler);
+    important ? handlers.unshift(newHandler) : handlers.push(newHandler);
   } else if (handlers) {
-    events[name] = [handlers, newHandler];
+    events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
   } else {
     events[name] = newHandler;
   }
@@ -3711,19 +3727,25 @@ function genHandler(handler) {
   } else if (!handler.modifiers) {
     return simplePathRE.test(handler.value) ? handler.value : 'function($event){' + handler.value + '}';
   } else {
-    var code = 'function($event){';
+    var code = '';
+    var keys = [];
     for (var key in handler.modifiers) {
-      code += modifierCode[key] || genKeyFilter(key);
+      if (modifierCode[key]) {
+        code += modifierCode[key];
+      } else {
+        keys.push(key);
+      }
+    }
+    if (keys.length) {
+      code = genKeyFilter(keys) + code;
     }
     var handlerCode = simplePathRE.test(handler.value) ? handler.value + '($event)' : handler.value;
-    return code + handlerCode + '}';
+    return 'function($event){' + code + handlerCode + '}';
   }
 }
 
-function genKeyFilter(key) {
-  var code = parseInt(key, 10) || // number keyCode
-  keyCodes[key] || // built-in alias
-  '_k(' + JSON.stringify(key) + ')'; // custom alias
+function genKeyFilter(keys) {
+  var code = keys.length === 1 ? normalizeKeyCode(keys[0]) : Array.prototype.concat.apply([], keys.map(normalizeKeyCode));
   if (Array.isArray(code)) {
     return 'if(' + code.map(function (c) {
       return '$event.keyCode!==' + c;
@@ -3733,6 +3755,13 @@ function genKeyFilter(key) {
   }
 }
 
+function normalizeKeyCode(key) {
+  return parseInt(key, 10) || // number keyCode
+  keyCodes[key] || // built-in alias
+  '_k(' + JSON.stringify(key) + ')' // custom alias
+  ;
+}
+
 function bind$1(el, dir) {
   addHook(el, 'construct', '_b(n1,' + dir.value + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ')');
 }
@@ -3855,11 +3884,6 @@ function genData(el) {
   for (var i = 0; i < dataGenFns.length; i++) {
     data += dataGenFns[i](el);
   }
-  // v-show, used to avoid transition being applied
-  // since v-show takes it over
-  if (el.attrsMap['v-show']) {
-    data += 'show:true,';
-  }
   // attributes
   if (el.attrs) {
     data += 'attrs:{' + genProps(el.attrs) + '},';
@@ -4133,7 +4157,7 @@ function genCheckboxModel(el, value) {
   var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
   var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
   addProp(el, 'checked', 'Array.isArray(' + value + ')' + ('?(' + value + ').indexOf(' + valueBinding + ')>-1') + (':(' + value + ')===(' + trueValueBinding + ')'));
-  addHandler(el, 'change', 'var $$a=' + value + ',' + '$$el=$event.target,' + ('$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');') + 'if(Array.isArray($$a)){' + ('var $$v=' + valueBinding + ',') + '$$i=$$a.indexOf($$v);' + ('if($$c){$$i<0&&(' + value + '=$$a.concat($$v))}') + ('else{$$i>-1&&(' + value + '=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}') + ('}else{' + value + '=$$c}'));
+  addHandler(el, 'change', 'var $$a=' + value + ',' + '$$el=$event.target,' + ('$$c=$$el.checked?(' + trueValueBinding + '):(' + falseValueBinding + ');') + 'if(Array.isArray($$a)){' + ('var $$v=' + valueBinding + ',') + '$$i=$$a.indexOf($$v);' + ('if($$c){$$i<0&&(' + value + '=$$a.concat($$v))}') + ('else{$$i>-1&&(' + value + '=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}') + ('}else{' + value + '=$$c}'), null, true);
 }
 
 function genRadioModel(el, value) {
@@ -4142,7 +4166,7 @@ function genRadioModel(el, value) {
   }
   var valueBinding = getBindingAttr(el, 'value');
   addProp(el, 'checked', '(' + value + ')===(' + valueBinding + ')');
-  addHandler(el, 'change', value + '=' + valueBinding);
+  addHandler(el, 'change', value + '=' + valueBinding, null, true);
 }
 
 function genDefaultModel(el, value, modifiers) {
@@ -4173,7 +4197,7 @@ function genDefaultModel(el, value, modifiers) {
     code = 'if($event.target.composing)return;' + code;
   }
   addProp(el, 'value', isNative ? '_s(' + value + ')' : '(' + value + ')');
-  addHandler(el, event, code);
+  addHandler(el, event, code, null, true);
   if (needCompositionGuard) {
     // need runtime directive code to help with composition events
     return true;
@@ -4185,7 +4209,7 @@ function genSelect(el, value) {
     el.children.some(checkOptionWarning);
   }
   var code = value + '=Array.prototype.filter' + '.call($event.target.options,function(o){return o.selected})' + '.map(function(o){return "_value" in o ? o._value : o.value})' + (el.attrsMap.multiple == null ? '[0]' : '');
-  addHandler(el, 'change', code);
+  addHandler(el, 'change', code, null, true);
   // need runtime to help with possible dynamically generated options
   return true;
 }
@@ -4363,7 +4387,8 @@ function compile(template, options) {
   options = options || {};
   var errors = [];
   // allow injecting modules/directives
-  var modules = options.modules ? baseOptions.modules.concat(options.modules) : baseOptions.modules;
+  var baseModules = baseOptions.modules || [];
+  var modules = options.modules ? baseModules.concat(options.modules) : baseModules;
   var directives = options.directives ? extend(extend({}, baseOptions.directives), options.directives) : baseOptions.directives;
   var compiled = compile$1(template, {
     modules: modules,

+ 1 - 1
packages/vue-template-compiler/package.json

@@ -1,6 +1,6 @@
 {
   "name": "vue-template-compiler",
-  "version": "2.0.0-rc.2",
+  "version": "2.0.0-rc.3",
   "description": "template compiler for Vue 2.0",
   "main": "index.js",
   "repository": {

+ 1 - 1
src/core/index.js

@@ -8,6 +8,6 @@ Object.defineProperty(Vue.prototype, '$isServer', {
   get: () => config._isServer
 })
 
-Vue.version = '2.0.0-rc.2'
+Vue.version = '2.0.0-rc.3'
 
 export default Vue

Некоторые файлы не были показаны из-за большого количества измененных файлов