Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: order watchers after trigger (#510)
- Loading branch information
1 parent
21fe83d
commit 8fee45a
Showing
5 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let i = 0 | ||
|
||
function orderDeps (watcher) { | ||
watcher.deps.forEach(dep => { | ||
if (dep._sortedId === i) { | ||
return | ||
} | ||
dep._sortedId = i | ||
dep.subs.forEach(orderDeps) | ||
dep.subs = dep.subs.sort((a, b) => a.id - b.id) | ||
}) | ||
} | ||
|
||
function orderVmWatchers (vm) { | ||
if (vm._watchers) { | ||
vm._watchers.forEach(orderDeps) | ||
} | ||
|
||
if (vm._computedWatchers) { | ||
Object.keys(vm._computedWatchers).forEach((computedWatcher) => { | ||
orderDeps(vm._computedWatchers[computedWatcher]) | ||
}) | ||
} | ||
|
||
orderDeps(vm._watcher) | ||
|
||
vm.$children.forEach(orderVmWatchers) | ||
} | ||
|
||
export function orderWatchers (vm) { | ||
orderVmWatchers(vm) | ||
i++ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
function setDepsSync (dep) { | ||
dep.subs = dep.subs.sort((a, b) => a.id - b.id) | ||
dep.subs.forEach(setWatcherSync) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters