Skip to content

Commit 80ac5c6

Browse files
miccycnyyx990803
authored andcommitted
fix the bug of UIwebview.MutationObserver not working exception in iO… (vuejs#3027)
* fix the bug of UIwebview.MutationObserver not working exception in iOS 9.3.* * fix the bug of UIwebview.MutationObserver not working exception in iOS 9.3.* * Update env.js Fixed: MutationObserver not working in iOS 9.3.* UIWebView * Fixed: MutationObserver not working in iOS 9.3.* UIWebView
1 parent 17690bf commit 80ac5c6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/util/env.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ const UA = inBrowser && window.navigator.userAgent.toLowerCase()
1616
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0
1717
export const isAndroid = UA && UA.indexOf('android') > 0
1818
export const isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA)
19-
export const isWechat = UA && UA.indexOf('micromessenger') > 0
19+
export const iosVersionMatch = isIos && UA.match(/os ([\d_]+)/)
20+
export const iosVersion = iosVersionMatch && iosVersionMatch[1].split('_')
21+
22+
// detecting iOS UIWebView by indexedDB
23+
export const hasMutationObserverBug = iosVersion && Number(iosVersion[0]) >= 9 && Number(iosVersion[1]) >= 3 && !window.indexedDB
2024

2125
let transitionProp
2226
let transitionEndEvent
@@ -76,7 +80,7 @@ export const nextTick = (function () {
7680
}
7781

7882
/* istanbul ignore if */
79-
if (typeof MutationObserver !== 'undefined' && !(isWechat && isIos)) {
83+
if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
8084
var counter = 1
8185
var observer = new MutationObserver(nextTickHandler)
8286
var textNode = document.createTextNode(counter)

0 commit comments

Comments
 (0)