Browse Source

[build] 2.0.0-rc.8

Evan You 9 years ago
parent
commit
ccd44f3f41

+ 46 - 18
dist/vue.common.js

@@ -355,6 +355,7 @@ function parsePath (path) {
 }
 
 /*  */
+/* globals MutationObserver */
 
 // can we use __proto__?
 var hasProto = '__proto__' in {}
@@ -369,10 +370,16 @@ var isIE = UA && /msie|trident/.test(UA)
 var isIE9 = UA && UA.indexOf('msie 9.0') > 0
 var isEdge = UA && UA.indexOf('edge/') > 0
 var isAndroid = UA && UA.indexOf('android') > 0
+var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA)
 
 // detect devtools
 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__
 
+/* istanbul ignore next */
+function isNative (Ctor) {
+  return /native code/.test(Ctor.toString())
+}
+
 /**
  * Defer a task to execute it asynchronously. Ideally this
  * should be executed as a microtask, but MutationObserver is unreliable
@@ -386,28 +393,47 @@ var nextTick = (function () {
   function nextTickHandler () {
     pending = false
     var copies = callbacks.slice(0)
-    callbacks = []
+    callbacks.length = 0
     for (var i = 0; i < copies.length; i++) {
       copies[i]()
     }
   }
 
-  /* istanbul ignore else */
-  if (inBrowser && window.postMessage &&
-    !window.importScripts && // not in WebWorker
-    !(isAndroid && !window.requestAnimationFrame) // not in Android <= 4.3
-  ) {
-    var NEXT_TICK_TOKEN = '__vue__nextTick__'
-    window.addEventListener('message', function (e) {
-      if (e.source === window && e.data === NEXT_TICK_TOKEN) {
-        nextTickHandler()
-      }
+  // the nextTick behavior leverages the microtask queue, which can be accessed
+  // via either native Promise.then or MutationObserver.
+  // MutationObserver has wider support, however it is seriously bugged in
+  // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
+  // completely stops working after triggering a few times... so, if native
+  // Promise is available, we will use it:
+  /* istanbul ignore if */
+  if (typeof Promise !== 'undefined' && isNative(Promise)) {
+    var p = Promise.resolve()
+    timerFunc = function () {
+      p.then(nextTickHandler)
+      // in problematic UIWebViews, Promise.then doesn't completely break, but
+      // it can get stuck in a weird state where callbacks are pushed into the
+      // microtask queue but the queue isn't being flushed, until the browser
+      // needs to do some other work, e.g. handle a timer. Therefore we can
+      // "force" the microtask queue to be flushed by adding an empty timer.
+      if (isIOS) { setTimeout(noop) }
+    }
+  } else if (typeof MutationObserver !== 'undefined') {
+    // use MutationObserver where native Promise is not available,
+    // e.g. IE11, iOS7, Android 4.4
+    var counter = 1
+    var observer = new MutationObserver(nextTickHandler)
+    var textNode = document.createTextNode(String(counter))
+    observer.observe(textNode, {
+      characterData: true
     })
     timerFunc = function () {
-      window.postMessage(NEXT_TICK_TOKEN, '*')
+      counter = (counter + 1) % 2
+      textNode.data = String(counter)
     }
   } else {
-    timerFunc = (typeof global !== 'undefined' && global.setImmediate) || setTimeout
+    // fallback to setTimeout
+    /* istanbul ignore next */
+    timerFunc = setTimeout
   }
 
   return function queueNextTick (cb, ctx) {
@@ -415,15 +441,16 @@ var nextTick = (function () {
       ? function () { cb.call(ctx) }
       : cb
     callbacks.push(func)
-    if (pending) { return }
-    pending = true
-    timerFunc(nextTickHandler, 0)
+    if (!pending) {
+      pending = true
+      timerFunc(nextTickHandler, 0)
+    }
   }
 })()
 
 var _Set
 /* istanbul ignore if */
-if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) {
+if (typeof Set !== 'undefined' && isNative(Set)) {
   // use native Set when available.
   _Set = Set
 } else {
@@ -3078,6 +3105,7 @@ var util = Object.freeze({
 	isIE9: isIE9,
 	isEdge: isEdge,
 	isAndroid: isAndroid,
+	isIOS: isIOS,
 	devtools: devtools,
 	nextTick: nextTick,
 	get _Set () { return _Set; },
@@ -3297,7 +3325,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
   get: function () { return config._isServer; }
 })
 
-Vue.version = '2.0.0-rc.7'
+Vue.version = '2.0.0-rc.8'
 
 /*  */
 

+ 56 - 19
dist/vue.js

@@ -1,5 +1,5 @@
 /*!
- * Vue.js v2.0.0-rc.7
+ * Vue.js v2.0.0-rc.8
  * (c) 2014-2016 Evan You
  * Released under the MIT License.
  */
@@ -364,6 +364,7 @@ function parsePath (path) {
 }
 
 /*  */
+/* globals MutationObserver */
 
 // can we use __proto__?
 var hasProto = '__proto__' in {}
@@ -378,10 +379,16 @@ var isIE = UA && /msie|trident/.test(UA)
 var isIE9 = UA && UA.indexOf('msie 9.0') > 0
 var isEdge = UA && UA.indexOf('edge/') > 0
 var isAndroid = UA && UA.indexOf('android') > 0
+var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA)
 
 // detect devtools
 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__
 
+/* istanbul ignore next */
+function isNative (Ctor) {
+  return /native code/.test(Ctor.toString())
+}
+
 /**
  * Defer a task to execute it asynchronously. Ideally this
  * should be executed as a microtask, but MutationObserver is unreliable
@@ -395,28 +402,47 @@ var nextTick = (function () {
   function nextTickHandler () {
     pending = false
     var copies = callbacks.slice(0)
-    callbacks = []
+    callbacks.length = 0
     for (var i = 0; i < copies.length; i++) {
       copies[i]()
     }
   }
 
-  /* istanbul ignore else */
-  if (inBrowser && window.postMessage &&
-    !window.importScripts && // not in WebWorker
-    !(isAndroid && !window.requestAnimationFrame) // not in Android <= 4.3
-  ) {
-    var NEXT_TICK_TOKEN = '__vue__nextTick__'
-    window.addEventListener('message', function (e) {
-      if (e.source === window && e.data === NEXT_TICK_TOKEN) {
-        nextTickHandler()
-      }
+  // the nextTick behavior leverages the microtask queue, which can be accessed
+  // via either native Promise.then or MutationObserver.
+  // MutationObserver has wider support, however it is seriously bugged in
+  // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
+  // completely stops working after triggering a few times... so, if native
+  // Promise is available, we will use it:
+  /* istanbul ignore if */
+  if (typeof Promise !== 'undefined' && isNative(Promise)) {
+    var p = Promise.resolve()
+    timerFunc = function () {
+      p.then(nextTickHandler)
+      // in problematic UIWebViews, Promise.then doesn't completely break, but
+      // it can get stuck in a weird state where callbacks are pushed into the
+      // microtask queue but the queue isn't being flushed, until the browser
+      // needs to do some other work, e.g. handle a timer. Therefore we can
+      // "force" the microtask queue to be flushed by adding an empty timer.
+      if (isIOS) { setTimeout(noop) }
+    }
+  } else if (typeof MutationObserver !== 'undefined') {
+    // use MutationObserver where native Promise is not available,
+    // e.g. IE11, iOS7, Android 4.4
+    var counter = 1
+    var observer = new MutationObserver(nextTickHandler)
+    var textNode = document.createTextNode(String(counter))
+    observer.observe(textNode, {
+      characterData: true
     })
     timerFunc = function () {
-      window.postMessage(NEXT_TICK_TOKEN, '*')
+      counter = (counter + 1) % 2
+      textNode.data = String(counter)
     }
   } else {
-    timerFunc = (typeof global !== 'undefined' && global.setImmediate) || setTimeout
+    // fallback to setTimeout
+    /* istanbul ignore next */
+    timerFunc = setTimeout
   }
 
   return function queueNextTick (cb, ctx) {
@@ -424,15 +450,16 @@ var nextTick = (function () {
       ? function () { cb.call(ctx) }
       : cb
     callbacks.push(func)
-    if (pending) { return }
-    pending = true
-    timerFunc(nextTickHandler, 0)
+    if (!pending) {
+      pending = true
+      timerFunc(nextTickHandler, 0)
+    }
   }
 })()
 
 var _Set
 /* istanbul ignore if */
-if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) {
+if (typeof Set !== 'undefined' && isNative(Set)) {
   // use native Set when available.
   _Set = Set
 } else {
@@ -3083,6 +3110,7 @@ var util = Object.freeze({
 	isIE9: isIE9,
 	isEdge: isEdge,
 	isAndroid: isAndroid,
+	isIOS: isIOS,
 	devtools: devtools,
 	nextTick: nextTick,
 	get _Set () { return _Set; },
@@ -3302,7 +3330,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
   get: function () { return config._isServer; }
 })
 
-Vue.version = '2.0.0-rc.7'
+Vue.version = '2.0.0-rc.8'
 
 /*  */
 
@@ -7125,6 +7153,15 @@ function genDefaultModel (
   if (isNative && needCompositionGuard) {
     code = "if($event.target.composing)return;" + code
   }
+  // inputs with type="file" are read only and setting the input's
+  // value will throw an error.
+  if ("development" !== 'production' &&
+      type === 'file') {
+    warn$3(
+      "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
+      "File inputs are read only. Use a v-on:change listener instead."
+    )
+  }
   addProp(el, 'value', isNative ? ("_s(" + value + ")") : ("(" + value + ")"))
   addHandler(el, event, code, null, true)
   if (needCompositionGuard) {

File diff suppressed because it is too large
+ 1 - 1
dist/vue.min.js


+ 53 - 17
packages/vue-server-renderer/build.js

@@ -355,6 +355,7 @@ function looseIndexOf (arr, val) {
 }
 
 /*  */
+/* globals MutationObserver */
 
 // can we use __proto__?
 var hasProto = '__proto__' in {}
@@ -369,10 +370,16 @@ var isIE = UA && /msie|trident/.test(UA)
 var isIE9 = UA && UA.indexOf('msie 9.0') > 0
 var isEdge = UA && UA.indexOf('edge/') > 0
 var isAndroid = UA && UA.indexOf('android') > 0
+var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA)
 
 // detect devtools
 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__
 
+/* istanbul ignore next */
+function isNative (Ctor) {
+  return /native code/.test(Ctor.toString())
+}
+
 /**
  * Defer a task to execute it asynchronously. Ideally this
  * should be executed as a microtask, but MutationObserver is unreliable
@@ -386,28 +393,47 @@ var nextTick = (function () {
   function nextTickHandler () {
     pending = false
     var copies = callbacks.slice(0)
-    callbacks = []
+    callbacks.length = 0
     for (var i = 0; i < copies.length; i++) {
       copies[i]()
     }
   }
 
-  /* istanbul ignore else */
-  if (inBrowser && window.postMessage &&
-    !window.importScripts && // not in WebWorker
-    !(isAndroid && !window.requestAnimationFrame) // not in Android <= 4.3
-  ) {
-    var NEXT_TICK_TOKEN = '__vue__nextTick__'
-    window.addEventListener('message', function (e) {
-      if (e.source === window && e.data === NEXT_TICK_TOKEN) {
-        nextTickHandler()
-      }
+  // the nextTick behavior leverages the microtask queue, which can be accessed
+  // via either native Promise.then or MutationObserver.
+  // MutationObserver has wider support, however it is seriously bugged in
+  // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
+  // completely stops working after triggering a few times... so, if native
+  // Promise is available, we will use it:
+  /* istanbul ignore if */
+  if (typeof Promise !== 'undefined' && isNative(Promise)) {
+    var p = Promise.resolve()
+    timerFunc = function () {
+      p.then(nextTickHandler)
+      // in problematic UIWebViews, Promise.then doesn't completely break, but
+      // it can get stuck in a weird state where callbacks are pushed into the
+      // microtask queue but the queue isn't being flushed, until the browser
+      // needs to do some other work, e.g. handle a timer. Therefore we can
+      // "force" the microtask queue to be flushed by adding an empty timer.
+      if (isIOS) { setTimeout(noop) }
+    }
+  } else if (typeof MutationObserver !== 'undefined') {
+    // use MutationObserver where native Promise is not available,
+    // e.g. IE11, iOS7, Android 4.4
+    var counter = 1
+    var observer = new MutationObserver(nextTickHandler)
+    var textNode = document.createTextNode(String(counter))
+    observer.observe(textNode, {
+      characterData: true
     })
     timerFunc = function () {
-      window.postMessage(NEXT_TICK_TOKEN, '*')
+      counter = (counter + 1) % 2
+      textNode.data = String(counter)
     }
   } else {
-    timerFunc = (typeof global !== 'undefined' && global.setImmediate) || setTimeout
+    // fallback to setTimeout
+    /* istanbul ignore next */
+    timerFunc = setTimeout
   }
 
   return function queueNextTick (cb, ctx) {
@@ -415,15 +441,16 @@ var nextTick = (function () {
       ? function () { cb.call(ctx) }
       : cb
     callbacks.push(func)
-    if (pending) { return }
-    pending = true
-    timerFunc(nextTickHandler, 0)
+    if (!pending) {
+      pending = true
+      timerFunc(nextTickHandler, 0)
+    }
   }
 })()
 
 var _Set
 /* istanbul ignore if */
-if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) {
+if (typeof Set !== 'undefined' && isNative(Set)) {
   // use native Set when available.
   _Set = Set
 } else {
@@ -4957,6 +4984,15 @@ function genDefaultModel (
   if (isNative && needCompositionGuard) {
     code = "if($event.target.composing)return;" + code
   }
+  // inputs with type="file" are read only and setting the input's
+  // value will throw an error.
+  if (process.env.NODE_ENV !== 'production' &&
+      type === 'file') {
+    warn$3(
+      "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
+      "File inputs are read only. Use a v-on:change listener instead."
+    )
+  }
   addProp(el, 'value', isNative ? ("_s(" + value + ")") : ("(" + value + ")"))
   addHandler(el, event, code, null, true)
   if (needCompositionGuard) {

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

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

+ 53 - 17
packages/vue-template-compiler/build.js

@@ -229,6 +229,7 @@ function looseIndexOf (arr, val) {
 }
 
 /*  */
+/* globals MutationObserver */
 
 // can we use __proto__?
 var hasProto = '__proto__' in {}
@@ -243,10 +244,16 @@ var isIE = UA && /msie|trident/.test(UA)
 var isIE9 = UA && UA.indexOf('msie 9.0') > 0
 var isEdge = UA && UA.indexOf('edge/') > 0
 var isAndroid = UA && UA.indexOf('android') > 0
+var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA)
 
 // detect devtools
 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__
 
+/* istanbul ignore next */
+function isNative (Ctor) {
+  return /native code/.test(Ctor.toString())
+}
+
 /**
  * Defer a task to execute it asynchronously. Ideally this
  * should be executed as a microtask, but MutationObserver is unreliable
@@ -260,28 +267,47 @@ var nextTick = (function () {
   function nextTickHandler () {
     pending = false
     var copies = callbacks.slice(0)
-    callbacks = []
+    callbacks.length = 0
     for (var i = 0; i < copies.length; i++) {
       copies[i]()
     }
   }
 
-  /* istanbul ignore else */
-  if (inBrowser && window.postMessage &&
-    !window.importScripts && // not in WebWorker
-    !(isAndroid && !window.requestAnimationFrame) // not in Android <= 4.3
-  ) {
-    var NEXT_TICK_TOKEN = '__vue__nextTick__'
-    window.addEventListener('message', function (e) {
-      if (e.source === window && e.data === NEXT_TICK_TOKEN) {
-        nextTickHandler()
-      }
+  // the nextTick behavior leverages the microtask queue, which can be accessed
+  // via either native Promise.then or MutationObserver.
+  // MutationObserver has wider support, however it is seriously bugged in
+  // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
+  // completely stops working after triggering a few times... so, if native
+  // Promise is available, we will use it:
+  /* istanbul ignore if */
+  if (typeof Promise !== 'undefined' && isNative(Promise)) {
+    var p = Promise.resolve()
+    timerFunc = function () {
+      p.then(nextTickHandler)
+      // in problematic UIWebViews, Promise.then doesn't completely break, but
+      // it can get stuck in a weird state where callbacks are pushed into the
+      // microtask queue but the queue isn't being flushed, until the browser
+      // needs to do some other work, e.g. handle a timer. Therefore we can
+      // "force" the microtask queue to be flushed by adding an empty timer.
+      if (isIOS) { setTimeout(noop) }
+    }
+  } else if (typeof MutationObserver !== 'undefined') {
+    // use MutationObserver where native Promise is not available,
+    // e.g. IE11, iOS7, Android 4.4
+    var counter = 1
+    var observer = new MutationObserver(nextTickHandler)
+    var textNode = document.createTextNode(String(counter))
+    observer.observe(textNode, {
+      characterData: true
     })
     timerFunc = function () {
-      window.postMessage(NEXT_TICK_TOKEN, '*')
+      counter = (counter + 1) % 2
+      textNode.data = String(counter)
     }
   } else {
-    timerFunc = (typeof global !== 'undefined' && global.setImmediate) || setTimeout
+    // fallback to setTimeout
+    /* istanbul ignore next */
+    timerFunc = setTimeout
   }
 
   return function queueNextTick (cb, ctx) {
@@ -289,15 +315,16 @@ var nextTick = (function () {
       ? function () { cb.call(ctx) }
       : cb
     callbacks.push(func)
-    if (pending) { return }
-    pending = true
-    timerFunc(nextTickHandler, 0)
+    if (!pending) {
+      pending = true
+      timerFunc(nextTickHandler, 0)
+    }
   }
 })()
 
 var _Set
 /* istanbul ignore if */
-if (typeof Set !== 'undefined' && /native code/.test(Set.toString())) {
+if (typeof Set !== 'undefined' && isNative(Set)) {
   // use native Set when available.
   _Set = Set
 } else {
@@ -4742,6 +4769,15 @@ function genDefaultModel (
   if (isNative && needCompositionGuard) {
     code = "if($event.target.composing)return;" + code
   }
+  // inputs with type="file" are read only and setting the input's
+  // value will throw an error.
+  if (process.env.NODE_ENV !== 'production' &&
+      type === 'file') {
+    warn$3(
+      "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
+      "File inputs are read only. Use a v-on:change listener instead."
+    )
+  }
   addProp(el, 'value', isNative ? ("_s(" + value + ")") : ("(" + value + ")"))
   addHandler(el, event, code, null, true)
   if (needCompositionGuard) {

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

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

Some files were not shown because too many files changed in this diff