File tree Expand file tree Collapse file tree 4 files changed +16
-10
lines changed Expand file tree Collapse file tree 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+
15## 1.4.3
26
37- fix: memory leak caused by unused ` @Setup ` decorator
Original file line number Diff line number Diff line change 11{
22 "name" : " vue-class-setup" ,
3- "version" : " 1.4.3 " ,
3+ "version" : " 1.4.4 " ,
44 "main" : " dist/index.cjs.js" ,
55 "module" : " dist/index.es.js" ,
66 "types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 11let count = 0 ;
2- let isOpen = false ;
2+ let isBind = false ;
33
4- export function add ( ) {
5- if ( isOpen ) {
4+ export function addCount ( ) {
5+ // 如果还是处于绑定状态,说明上一次解绑的过程中程序执行报错了,需要重置
6+ if ( isBind ) {
7+ isBind = false ;
68 count = 1 ;
79 } else {
8- isOpen = true ;
910 count ++ ;
1011 }
1112}
1213
1314const weakMap = new WeakMap < object , number > ( ) ;
1415
15- export function popTarget ( target : object ) : boolean {
16+ export function unBindTarget ( target : object ) : boolean {
1617 let count = weakMap . get ( target ) ;
1718 if ( typeof count === 'number' ) {
1819 count -- ;
@@ -21,7 +22,7 @@ export function popTarget(target: object): boolean {
2122 return false ;
2223 } else {
2324 weakMap . delete ( target ) ;
24- isOpen = false ;
25+ isBind = false ;
2526 return true ;
2627 }
2728 }
@@ -32,6 +33,7 @@ export function bindTarget(target: object) {
3233 if ( count > 0 ) {
3334 weakMap . set ( target , count ) ;
3435 count = 0 ;
36+ isBind = true ;
3537 } else {
3638 console . warn ( `The instance did not use the '@Setup' decorator` ) ;
3739 }
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
1010import { initComputed } from './computed' ;
1111import { getOptions , getSetupOptions } from './options' ;
1212import { initDefine } from './define' ;
13- import { add , popTarget } from './setup-reference' ;
13+ import { addCount , unBindTarget } from './setup-reference' ;
1414import { getPropertyDescriptors } from './property-descriptors' ;
1515
1616export type TargetConstructor = {
@@ -68,9 +68,9 @@ function Setup<T extends TargetConstructor>(Target: T) {
6868 public static [ SETUP_PROPERTY_DESCRIPTOR ] =
6969 getPropertyDescriptors ( Target ) ;
7070 public constructor ( ...args : any [ ] ) {
71- add ( ) ;
71+ addCount ( ) ;
7272 super ( ...args ) ;
73- if ( popTarget ( this ) ) {
73+ if ( unBindTarget ( this ) ) {
7474 // Vue3 needs to return, vue2 does not need to return
7575 return initHook ( reactive ( this ) ) ;
7676 }
You can’t perform that action at this time.
0 commit comments