File tree 4 files changed +16
-10
lines changed
4 files changed +16
-10
lines changed Original file line number Diff line number Diff line change
1
+ ## 1.4.4
2
+
3
+ - fix: multiple inheritance unbinding object errors
4
+
1
5
## 1.4.3
2
6
3
7
- fix: memory leak caused by unused ` @Setup ` decorator
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " vue-class-setup" ,
3
- "version" : " 1.4.3 " ,
3
+ "version" : " 1.4.4 " ,
4
4
"main" : " dist/index.cjs.js" ,
5
5
"module" : " dist/index.es.js" ,
6
6
"types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 1
1
let count = 0 ;
2
- let isOpen = false ;
2
+ let isBind = false ;
3
3
4
- export function add ( ) {
5
- if ( isOpen ) {
4
+ export function addCount ( ) {
5
+ // 如果还是处于绑定状态,说明上一次解绑的过程中程序执行报错了,需要重置
6
+ if ( isBind ) {
7
+ isBind = false ;
6
8
count = 1 ;
7
9
} else {
8
- isOpen = true ;
9
10
count ++ ;
10
11
}
11
12
}
12
13
13
14
const weakMap = new WeakMap < object , number > ( ) ;
14
15
15
- export function popTarget ( target : object ) : boolean {
16
+ export function unBindTarget ( target : object ) : boolean {
16
17
let count = weakMap . get ( target ) ;
17
18
if ( typeof count === 'number' ) {
18
19
count -- ;
@@ -21,7 +22,7 @@ export function popTarget(target: object): boolean {
21
22
return false ;
22
23
} else {
23
24
weakMap . delete ( target ) ;
24
- isOpen = false ;
25
+ isBind = false ;
25
26
return true ;
26
27
}
27
28
}
@@ -32,6 +33,7 @@ export function bindTarget(target: object) {
32
33
if ( count > 0 ) {
33
34
weakMap . set ( target , count ) ;
34
35
count = 0 ;
36
+ isBind = true ;
35
37
} else {
36
38
console . warn ( `The instance did not use the '@Setup' decorator` ) ;
37
39
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
10
10
import { initComputed } from './computed' ;
11
11
import { getOptions , getSetupOptions } from './options' ;
12
12
import { initDefine } from './define' ;
13
- import { add , popTarget } from './setup-reference' ;
13
+ import { addCount , unBindTarget } from './setup-reference' ;
14
14
import { getPropertyDescriptors } from './property-descriptors' ;
15
15
16
16
export type TargetConstructor = {
@@ -68,9 +68,9 @@ function Setup<T extends TargetConstructor>(Target: T) {
68
68
public static [ SETUP_PROPERTY_DESCRIPTOR ] =
69
69
getPropertyDescriptors ( Target ) ;
70
70
public constructor ( ...args : any [ ] ) {
71
- add ( ) ;
71
+ addCount ( ) ;
72
72
super ( ...args ) ;
73
- if ( popTarget ( this ) ) {
73
+ if ( unBindTarget ( this ) ) {
74
74
// Vue3 needs to return, vue2 does not need to return
75
75
return initHook ( reactive ( this ) ) ;
76
76
}
You can’t perform that action at this time.
0 commit comments