فهرست منبع

[build] 2.0.0-rc.1

Evan You 9 سال پیش
والد
کامیت
df85865e4f

+ 23 - 20
dist/vue.common.js

@@ -2542,7 +2542,7 @@ function validateProp(key, propOptions, propsData, vm) {
   var absent = !hasOwn(propsData, key);
   var value = propsData[key];
   // handle boolean props
-  if (prop.type === Boolean) {
+  if (getType(prop.type) === 'Boolean') {
     if (absent && !hasOwn(prop, 'default')) {
       value = false;
     } else if (value === '' || value === hyphenate(key)) {
@@ -2623,27 +2623,20 @@ function assertProp(prop, name, value, vm, absent) {
  */
 function assertType(value, type) {
   var valid = void 0;
-  var expectedType = void 0;
-  if (type === String) {
-    expectedType = 'string';
-    valid = typeof value === expectedType;
-  } else if (type === Number) {
-    expectedType = 'number';
-    valid = typeof value === expectedType;
-  } else if (type === Boolean) {
-    expectedType = 'boolean';
-    valid = typeof value === expectedType;
-  } else if (type === Function) {
-    expectedType = 'function';
-    valid = typeof value === expectedType;
-  } else if (type === Object) {
-    expectedType = 'Object';
+  var expectedType = getType(type);
+  if (expectedType === 'String') {
+    valid = typeof value === (expectedType = 'string');
+  } else if (expectedType === 'Number') {
+    valid = typeof value === (expectedType = 'number');
+  } else if (expectedType === 'Boolean') {
+    valid = typeof value === (expectedType = 'boolean');
+  } else if (expectedType === 'Function') {
+    valid = typeof value === (expectedType = 'function');
+  } else if (expectedType === 'Object') {
     valid = isPlainObject(value);
-  } else if (type === Array) {
-    expectedType = 'Array';
+  } else if (expectedType === 'Array') {
     valid = Array.isArray(value);
   } else {
-    expectedType = type.name || type.toString();
     valid = value instanceof type;
   }
   return {
@@ -2652,6 +2645,16 @@ function assertType(value, type) {
   };
 }
 
+/**
+ * Use function string name to check built-in types,
+ * because a simple equality check will fail when running
+ * across different vms / iframes.
+ */
+function getType(fn) {
+  var match = fn && fn.toString().match(/^\s*function (\w+)/);
+  return match && match[1];
+}
+
 
 
 var util = Object.freeze({
@@ -2879,7 +2882,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
   }
 });
 
-Vue.version = '2.0.0-beta.8';
+Vue.version = '2.0.0-rc.1';
 
 // attributes that should be using props for binding
 var mustUseProp = makeMap('value,selected,checked,muted');

+ 24 - 21
dist/vue.js

@@ -1,5 +1,5 @@
 /*!
- * Vue.js v2.0.0-beta.8
+ * Vue.js v2.0.0-rc.1
  * (c) 2014-2016 Evan You
  * Released under the MIT License.
  */
@@ -2547,7 +2547,7 @@
     var absent = !hasOwn(propsData, key);
     var value = propsData[key];
     // handle boolean props
-    if (prop.type === Boolean) {
+    if (getType(prop.type) === 'Boolean') {
       if (absent && !hasOwn(prop, 'default')) {
         value = false;
       } else if (value === '' || value === hyphenate(key)) {
@@ -2628,27 +2628,20 @@
    */
   function assertType(value, type) {
     var valid = void 0;
-    var expectedType = void 0;
-    if (type === String) {
-      expectedType = 'string';
-      valid = typeof value === expectedType;
-    } else if (type === Number) {
-      expectedType = 'number';
-      valid = typeof value === expectedType;
-    } else if (type === Boolean) {
-      expectedType = 'boolean';
-      valid = typeof value === expectedType;
-    } else if (type === Function) {
-      expectedType = 'function';
-      valid = typeof value === expectedType;
-    } else if (type === Object) {
-      expectedType = 'Object';
+    var expectedType = getType(type);
+    if (expectedType === 'String') {
+      valid = typeof value === (expectedType = 'string');
+    } else if (expectedType === 'Number') {
+      valid = typeof value === (expectedType = 'number');
+    } else if (expectedType === 'Boolean') {
+      valid = typeof value === (expectedType = 'boolean');
+    } else if (expectedType === 'Function') {
+      valid = typeof value === (expectedType = 'function');
+    } else if (expectedType === 'Object') {
       valid = isPlainObject(value);
-    } else if (type === Array) {
-      expectedType = 'Array';
+    } else if (expectedType === 'Array') {
       valid = Array.isArray(value);
     } else {
-      expectedType = type.name || type.toString();
       valid = value instanceof type;
     }
     return {
@@ -2657,6 +2650,16 @@
     };
   }
 
+  /**
+   * Use function string name to check built-in types,
+   * because a simple equality check will fail when running
+   * across different vms / iframes.
+   */
+  function getType(fn) {
+    var match = fn && fn.toString().match(/^\s*function (\w+)/);
+    return match && match[1];
+  }
+
 
 
   var util = Object.freeze({
@@ -2884,7 +2887,7 @@
     }
   });
 
-  Vue.version = '2.0.0-beta.8';
+  Vue.version = '2.0.0-rc.1';
 
   // attributes that should be using props for binding
   var mustUseProp = makeMap('value,selected,checked,muted');

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


+ 39 - 23
packages/vue-server-renderer/build.js

@@ -2653,7 +2653,7 @@ function validateProp(key, propOptions, propsData, vm) {
   var absent = !hasOwn(propsData, key);
   var value = propsData[key];
   // handle boolean props
-  if (prop.type === Boolean) {
+  if (getType(prop.type) === 'Boolean') {
     if (absent && !hasOwn(prop, 'default')) {
       value = false;
     } else if (value === '' || value === hyphenate(key)) {
@@ -2734,27 +2734,20 @@ function assertProp(prop, name, value, vm, absent) {
  */
 function assertType(value, type) {
   var valid = void 0;
-  var expectedType = void 0;
-  if (type === String) {
-    expectedType = 'string';
-    valid = typeof value === expectedType;
-  } else if (type === Number) {
-    expectedType = 'number';
-    valid = typeof value === expectedType;
-  } else if (type === Boolean) {
-    expectedType = 'boolean';
-    valid = typeof value === expectedType;
-  } else if (type === Function) {
-    expectedType = 'function';
-    valid = typeof value === expectedType;
-  } else if (type === Object) {
-    expectedType = 'Object';
+  var expectedType = getType(type);
+  if (expectedType === 'String') {
+    valid = typeof value === (expectedType = 'string');
+  } else if (expectedType === 'Number') {
+    valid = typeof value === (expectedType = 'number');
+  } else if (expectedType === 'Boolean') {
+    valid = typeof value === (expectedType = 'boolean');
+  } else if (expectedType === 'Function') {
+    valid = typeof value === (expectedType = 'function');
+  } else if (expectedType === 'Object') {
     valid = isPlainObject(value);
-  } else if (type === Array) {
-    expectedType = 'Array';
+  } else if (expectedType === 'Array') {
     valid = Array.isArray(value);
   } else {
-    expectedType = type.name || type.toString();
     valid = value instanceof type;
   }
   return {
@@ -2763,6 +2756,16 @@ function assertType(value, type) {
   };
 }
 
+/**
+ * Use function string name to check built-in types,
+ * because a simple equality check will fail when running
+ * across different vms / iframes.
+ */
+function getType(fn) {
+  var match = fn && fn.toString().match(/^\s*function (\w+)/);
+  return match && match[1];
+}
+
 // attributes that should be using props for binding
 var mustUseProp = makeMap('value,selected,checked,muted');
 
@@ -4484,6 +4487,14 @@ function makeFunction(code) {
   }
 }
 
+var warned = Object.create(null);
+var warnOnce = function warnOnce(msg) {
+  if (!warned[msg]) {
+    warned[msg] = true;
+    console.warn('\n\u001b[31m' + msg + '\u001b[39m\n');
+  }
+};
+
 var normalizeAsync = function normalizeAsync(cache, method) {
   var fn = cache[method];
   if (!fn) {
@@ -4531,9 +4542,10 @@ function createRenderFunction(modules, directives, isUnaryTag, cache) {
       // check cache hit
       var Ctor = node.componentOptions.Ctor;
       var getKey = Ctor.options.serverCacheKey;
-      if (getKey && cache) {
+      var name = Ctor.options.name;
+      if (getKey && cache && name) {
         (function () {
-          var key = Ctor.cid + '::' + getKey(node.componentOptions.propsData);
+          var key = name + '::' + getKey(node.componentOptions.propsData);
           if (has) {
             has(key, function (hit) {
               if (hit) {
@@ -4555,8 +4567,11 @@ function createRenderFunction(modules, directives, isUnaryTag, cache) {
           }
         })();
       } else {
-        if (getKey) {
-          console.error('[vue-server-renderer] Component ' + (Ctor.options.name || '(anonymous)') + ' implemented serverCacheKey, ' + 'but no cache was provided to the renderer.');
+        if (getKey && !cache) {
+          warnOnce('[vue-server-renderer] Component ' + (Ctor.options.name || '(anonymous)') + ' implemented serverCacheKey, ' + 'but no cache was provided to the renderer.');
+        }
+        if (getKey && !name) {
+          warnOnce('[vue-server-renderer] Components that implement "serverCacheKey" ' + 'must also define a unique "name" option.');
         }
         renderComponent(node, write, next, isRoot);
       }
@@ -4678,6 +4693,7 @@ function createRenderFunction(modules, directives, isUnaryTag, cache) {
   }
 
   return function render(component, write, done) {
+    warned = Object.create(null);
     activeInstance = component;
     normalizeRender(component);
     renderNode(component._render(), write, done, true);

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

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

+ 22 - 19
packages/vue-template-compiler/build.js

@@ -2512,7 +2512,7 @@ function validateProp(key, propOptions, propsData, vm) {
   var absent = !hasOwn(propsData, key);
   var value = propsData[key];
   // handle boolean props
-  if (prop.type === Boolean) {
+  if (getType(prop.type) === 'Boolean') {
     if (absent && !hasOwn(prop, 'default')) {
       value = false;
     } else if (value === '' || value === hyphenate(key)) {
@@ -2593,27 +2593,20 @@ function assertProp(prop, name, value, vm, absent) {
  */
 function assertType(value, type) {
   var valid = void 0;
-  var expectedType = void 0;
-  if (type === String) {
-    expectedType = 'string';
-    valid = typeof value === expectedType;
-  } else if (type === Number) {
-    expectedType = 'number';
-    valid = typeof value === expectedType;
-  } else if (type === Boolean) {
-    expectedType = 'boolean';
-    valid = typeof value === expectedType;
-  } else if (type === Function) {
-    expectedType = 'function';
-    valid = typeof value === expectedType;
-  } else if (type === Object) {
-    expectedType = 'Object';
+  var expectedType = getType(type);
+  if (expectedType === 'String') {
+    valid = typeof value === (expectedType = 'string');
+  } else if (expectedType === 'Number') {
+    valid = typeof value === (expectedType = 'number');
+  } else if (expectedType === 'Boolean') {
+    valid = typeof value === (expectedType = 'boolean');
+  } else if (expectedType === 'Function') {
+    valid = typeof value === (expectedType = 'function');
+  } else if (expectedType === 'Object') {
     valid = isPlainObject(value);
-  } else if (type === Array) {
-    expectedType = 'Array';
+  } else if (expectedType === 'Array') {
     valid = Array.isArray(value);
   } else {
-    expectedType = type.name || type.toString();
     valid = value instanceof type;
   }
   return {
@@ -2622,6 +2615,16 @@ function assertType(value, type) {
   };
 }
 
+/**
+ * Use function string name to check built-in types,
+ * because a simple equality check will fail when running
+ * across different vms / iframes.
+ */
+function getType(fn) {
+  var match = fn && fn.toString().match(/^\s*function (\w+)/);
+  return match && match[1];
+}
+
 // attributes that should be using props for binding
 var mustUseProp = makeMap('value,selected,checked,muted');
 

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

@@ -1,6 +1,6 @@
 {
   "name": "vue-template-compiler",
-  "version": "2.0.0-beta.8",
+  "version": "2.0.0-rc.1",
   "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-beta.8'
+Vue.version = '2.0.0-rc.1'
 
 export default Vue

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