* Flush both queues and run the watchers.
()
| 2313 | * Flush both queues and run the watchers. |
| 2314 | */ |
| 2315 | function flushSchedulerQueue () { |
| 2316 | flushing = true; |
| 2317 | var watcher, id, vm; |
| 2318 | |
| 2319 | // Sort queue before flush. |
| 2320 | // This ensures that: |
| 2321 | // 1. Components are updated from parent to child. (because parent is always |
| 2322 | // created before the child) |
| 2323 | // 2. A component's user watchers are run before its render watcher (because |
| 2324 | // user watchers are created before the render watcher) |
| 2325 | // 3. If a component is destroyed during a parent component's watcher run, |
| 2326 | // its watchers can be skipped. |
| 2327 | queue.sort(function (a, b) { return a.id - b.id; }); |
| 2328 | |
| 2329 | // do not cache length because more watchers might be pushed |
| 2330 | // as we run existing watchers |
| 2331 | for (index = 0; index < queue.length; index++) { |
| 2332 | watcher = queue[index]; |
| 2333 | id = watcher.id; |
| 2334 | has[id] = null; |
| 2335 | watcher.run(); |
| 2336 | // in dev build, check and stop circular updates. |
| 2337 | if ("development" !== 'production' && has[id] != null) { |
| 2338 | circular[id] = (circular[id] || 0) + 1; |
| 2339 | if (circular[id] > config._maxUpdateCount) { |
| 2340 | warn( |
| 2341 | 'You may have an infinite update loop ' + ( |
| 2342 | watcher.user |
| 2343 | ? ("in watcher with expression \"" + (watcher.expression) + "\"") |
| 2344 | : "in a component render function." |
| 2345 | ), |
| 2346 | watcher.vm |
| 2347 | ); |
| 2348 | break |
| 2349 | } |
| 2350 | } |
| 2351 | } |
| 2352 | |
| 2353 | // reset scheduler before updated hook called |
| 2354 | var oldQueue = queue.slice(); |
| 2355 | resetSchedulerState(); |
| 2356 | |
| 2357 | // call updated hooks |
| 2358 | index = oldQueue.length; |
| 2359 | while (index--) { |
| 2360 | watcher = oldQueue[index]; |
| 2361 | vm = watcher.vm; |
| 2362 | if (vm._watcher === watcher && vm._isMounted) { |
| 2363 | callHook(vm, 'updated'); |
| 2364 | } |
| 2365 | } |
| 2366 | |
| 2367 | // devtool hook |
| 2368 | /* istanbul ignore if */ |
| 2369 | if (devtools && config.devtools) { |
| 2370 | devtools.emit('flush'); |
| 2371 | } |
| 2372 | } |
nothing calls this directly
no test coverage detected