File tree Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Expand file tree Collapse file tree 1 file changed +18
-16
lines changed Original file line number Diff line number Diff line change @@ -17,20 +17,26 @@ module.exports = {
17
17
// without this it would stabilize too, but this makes
18
18
// sure it doesn't cause other watchers to re-evaluate.
19
19
var locked = false
20
+ function withLock ( fn ) {
21
+ return function ( val ) {
22
+ if ( ! locked ) {
23
+ locked = true
24
+ fn ( val )
25
+ _ . nextTick ( function ( ) {
26
+ locked = false
27
+ } )
28
+ }
29
+ }
30
+ }
20
31
21
32
this . parentWatcher = new Watcher (
22
33
parent ,
23
34
parentKey ,
24
- function ( val ) {
25
- if ( ! locked ) {
26
- locked = true
27
- // all props have been initialized already
28
- if ( _ . assertProp ( prop , val ) ) {
29
- child [ childKey ] = val
30
- }
31
- locked = false
35
+ withLock ( function ( val ) {
36
+ if ( _ . assertProp ( prop , val ) ) {
37
+ child [ childKey ] = val
32
38
}
33
- }
39
+ } )
34
40
)
35
41
36
42
// set the child initial value first, before setting
@@ -47,13 +53,9 @@ module.exports = {
47
53
this . childWatcher = new Watcher (
48
54
child ,
49
55
childKey ,
50
- function ( val ) {
51
- if ( ! locked ) {
52
- locked = true
53
- parent . $set ( parentKey , val )
54
- locked = false
55
- }
56
- }
56
+ withLock ( function ( val ) {
57
+ parent . $set ( parentKey , val )
58
+ } )
57
59
)
58
60
}
59
61
} ,
You can’t perform that action at this time.
0 commit comments