Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromvuejs/vue

Commit3b49a63

Browse files
committed
adjust nextTick implementation (fixvuejs#3730)
1 parentb2ab9fa commit3b49a63

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

‎src/util/env.js

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* global MutationObserver */
2-
31
// can we use __proto__?
42
exportconsthasProto='__proto__'in{}
53

@@ -16,21 +14,6 @@ const UA = inBrowser && window.navigator.userAgent.toLowerCase()
1614
exportconstisIE=UA&&UA.indexOf('trident')>0
1715
exportconstisIE9=UA&&UA.indexOf('msie 9.0')>0
1816
exportconstisAndroid=UA&&UA.indexOf('android')>0
19-
exportconstisIos=UA&&/(iphone|ipad|ipod|ios)/i.test(UA)
20-
exportconstiosVersionMatch=isIos&&UA.match(/os([\d_]+)/)
21-
exportconstiosVersion=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-
consthasMutationObserverBug=
27-
iosVersion&&
28-
!window.indexedDB&&(
29-
iosVersion[0]>9||(
30-
iosVersion[0]===9&&
31-
iosVersion[1]>=3
32-
)
33-
)
3417

3518
lettransitionProp
3619
lettransitionEndEvent
@@ -89,27 +72,24 @@ export const nextTick = (function () {
8972
}
9073
}
9174

92-
/* istanbul ignore if */
93-
if(typeofMutationObserver!=='undefined'&&!hasMutationObserverBug){
94-
varcounter=1
95-
varobserver=newMutationObserver(nextTickHandler)
96-
vartextNode=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+
constNEXT_TICK_TOKEN='__vue__nextTick__'
81+
window.addEventListener('message',e=>{
82+
if(e.source===window&&e.data===NEXT_TICK_TOKEN){
83+
nextTickHandler()
84+
}
9985
})
100-
timerFunc=function(){
101-
counter=(counter+1)%2
102-
textNode.data=counter
86+
timerFunc=()=>{
87+
window.postMessage(NEXT_TICK_TOKEN,'*')
10388
}
10489
}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-
constcontext=inBrowser
109-
?window
110-
:typeofglobal!=='undefined' ?global :{}
111-
timerFunc=context.setImmediate||setTimeout
90+
timerFunc=(typeofglobal!=='undefined'&&global.setImmediate)||setTimeout
11291
}
92+
11393
returnfunction(cb,ctx){
11494
varfunc=ctx
11595
?function(){cb.call(ctx)}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp