1
- /* global MutationObserver */
2
-
3
1
// can we use __proto__?
4
2
export const hasProto = '__proto__' in { }
5
3
@@ -16,21 +14,6 @@ const UA = inBrowser && window.navigator.userAgent.toLowerCase()
16
14
export const isIE = UA && UA . indexOf ( 'trident' ) > 0
17
15
export const isIE9 = UA && UA . indexOf ( 'msie 9.0' ) > 0
18
16
export const isAndroid = UA && UA . indexOf ( 'android' ) > 0
19
- export const isIos = UA && / ( i p h o n e | i p a d | i p o d | i o s ) / i. test ( UA )
20
- export const iosVersionMatch = isIos && UA . match ( / o s ( [ \d _ ] + ) / )
21
- export const iosVersion = iosVersionMatch && iosVersionMatch [ 1 ] . split ( '_' ) . map ( Number )
22
-
23
- // MutationObserver is unreliable in iOS 9.3 UIWebView
24
- // detecting it by checking presence of IndexedDB
25
- // ref #3027
26
- const hasMutationObserverBug =
27
- iosVersion &&
28
- ! window . indexedDB && (
29
- iosVersion [ 0 ] > 9 || (
30
- iosVersion [ 0 ] === 9 &&
31
- iosVersion [ 1 ] >= 3
32
- )
33
- )
34
17
35
18
let transitionProp
36
19
let transitionEndEvent
@@ -89,27 +72,24 @@ export const nextTick = (function () {
89
72
}
90
73
}
91
74
92
- /* istanbul ignore if */
93
- if ( typeof MutationObserver !== 'undefined' && ! hasMutationObserverBug ) {
94
- var counter = 1
95
- var observer = new MutationObserver ( nextTickHandler )
96
- var textNode = document . createTextNode ( counter )
97
- observer . observe ( textNode , {
98
- characterData : true
75
+ /* istanbul ignore else */
76
+ if ( inBrowser && window . postMessage &&
77
+ ! window . importScripts && // not in WebWorker
78
+ ! ( isAndroid && ! window . requestAnimationFrame ) // not in Android <= 4.3
79
+ ) {
80
+ const NEXT_TICK_TOKEN = '__vue__nextTick__'
81
+ window . addEventListener ( 'message' , e => {
82
+ if ( e . source === window && e . data === NEXT_TICK_TOKEN ) {
83
+ nextTickHandler ( )
84
+ }
99
85
} )
100
- timerFunc = function ( ) {
101
- counter = ( counter + 1 ) % 2
102
- textNode . data = counter
86
+ timerFunc = ( ) => {
87
+ window . postMessage ( NEXT_TICK_TOKEN , '*' )
103
88
}
104
89
} else {
105
- // webpack attempts to inject a shim for setImmediate
106
- // if it is used as a global, so we have to work around that to
107
- // avoid bundling unnecessary code.
108
- const context = inBrowser
109
- ? window
110
- : typeof global !== 'undefined' ? global : { }
111
- timerFunc = context . setImmediate || setTimeout
90
+ timerFunc = ( typeof global !== 'undefined' && global . setImmediate ) || setTimeout
112
91
}
92
+
113
93
return function ( cb , ctx ) {
114
94
var func = ctx
115
95
? function ( ) { cb . call ( ctx ) }
0 commit comments