8000 prioritize the MutationObserver (microtask) approach · vuejs/vue@38accc1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38accc1

Browse files
author
勾股
committed
prioritize the MutationObserver (microtask) approach
1 parent cc70556 commit 38accc1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/util/env.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ export const nextTick = (function () {
7272
}
7373

7474
/* istanbul ignore if */
75-
if (typeof setImmediate === 'function') {
76-
timerFunc = setImmediate
77-
} else if (typeof MutationObserver !== 'undefined') {
75+
if (typeof MutationObserver !== 'undefined') {
7876
var counter = 1
7977
var observer = new MutationObserver(nextTickHandler)
8078
var textNode = document.createTextNode(counter)
@@ -85,6 +83,8 @@ export const nextTick = (function () {
8583
counter = (counter + 1) % 2
8684
textNode.data = counter
8785
}
86+
} else if (typeof setImmediate === 'function') {
87+
timerFunc = setImmediate
8888
} else {
8989
timerFunc = setTimeout
9090
}

0 commit comments

Comments
 (0)
0