Skip to content

Commit 942ba3a

Browse files
committed
cherry-pick #3027 iOS 9.3 MutationObserver fix
1 parent a5a9dc9 commit 942ba3a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/core/util/env.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ export const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__
1515
// UA sniffing for working around browser-specific quirks
1616
const UA = inBrowser && window.navigator.userAgent.toLowerCase()
1717
const isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA)
18-
const isWechat = UA && UA.indexOf('micromessenger') > 0
18+
const iosVersionMatch = isIos && UA.match(/os ([\d_]+)/)
19+
const iosVersion = iosVersionMatch && iosVersionMatch[1].split('_')
20+
21+
// MutationObserver is unreliable in iOS 9.3 UIWebView
22+
// detecting it by checking presence of IndexedDB
23+
// ref #3027
24+
const hasMutationObserverBug =
25+
iosVersion &&
26+
Number(iosVersion[0]) >= 9 &&
27+
Number(iosVersion[1]) >= 3 &&
28+
!window.indexedDB
1929

2030
/**
2131
* Defer a task to execute it asynchronously. Ideally this
@@ -40,7 +50,7 @@ export const nextTick = (function () {
4050
}
4151

4252
/* istanbul ignore else */
43-
if (typeof MutationObserver !== 'undefined' && !(isWechat && isIos)) {
53+
if (typeof MutationObserver !== 'undefined' && !hasMutationObserverBug) {
4454
let counter = 1
4555
const observer = new MutationObserver(nextTickHandler)
4656
const textNode = document.createTextNode(String(counter))

0 commit comments

Comments
 (0)