@mpxjs/core 2.8.23 → 2.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/core/proxy.js +4 -2
- package/src/observer/effect.js +7 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/core",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.24",
|
|
4
4
|
"description": "mpx runtime core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"miniprogram",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"url": "https://github.com/didi/mpx/issues"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": false,
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "f019e3d3dc8b0c512e3e0f95f3f0b47f716e576c"
|
|
51
51
|
}
|
package/src/core/proxy.js
CHANGED
|
@@ -507,7 +507,7 @@ export default class MpxProxy {
|
|
|
507
507
|
initRender () {
|
|
508
508
|
if (this.options.__nativeRender__) return this.doRender()
|
|
509
509
|
|
|
510
|
-
this.effect = new ReactiveEffect(() => {
|
|
510
|
+
const effect = this.effect = new ReactiveEffect(() => {
|
|
511
511
|
if (this.target.__injectedRender) {
|
|
512
512
|
try {
|
|
513
513
|
return this.target.__injectedRender()
|
|
@@ -520,8 +520,10 @@ export default class MpxProxy {
|
|
|
520
520
|
}
|
|
521
521
|
}, () => queueJob(update), this.scope)
|
|
522
522
|
|
|
523
|
-
const update = this.effect.run.bind(this.effect)
|
|
523
|
+
const update = this.update = this.effect.run.bind(this.effect)
|
|
524
524
|
update.id = this.uid
|
|
525
|
+
// render effect允许自触发
|
|
526
|
+
effect.allowRecurse = update.allowRecurse = true
|
|
525
527
|
update()
|
|
526
528
|
}
|
|
527
529
|
|
package/src/observer/effect.js
CHANGED
|
@@ -10,6 +10,7 @@ export class ReactiveEffect {
|
|
|
10
10
|
newDeps = []
|
|
11
11
|
depIds = new Set()
|
|
12
12
|
newDepIds = new Set()
|
|
13
|
+
allowRecurse = false
|
|
13
14
|
|
|
14
15
|
constructor (
|
|
15
16
|
fn,
|
|
@@ -69,12 +70,12 @@ export class ReactiveEffect {
|
|
|
69
70
|
// same as trigger
|
|
70
71
|
update () {
|
|
71
72
|
// avoid dead cycle
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
if (Dep.target !== this || this.allowRecurse) {
|
|
74
|
+
if (this.pausedState !== PausedState.resumed) {
|
|
75
|
+
this.pausedState = PausedState.dirty
|
|
76
|
+
} else {
|
|
77
|
+
this.scheduler ? this.scheduler() : this.run()
|
|
78
|
+
}
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|