@@ -21,7 +21,7 @@ export default Vue.extend({
2121 } ,
2222 data ( ) {
2323 return {
24- dialogsData : new Map < symbol , DialogData < any , any > > ( ) ,
24+ dialogsData : { } as Record < symbol , DialogData < any , any > > ,
2525 } ;
2626 } ,
2727 created ( ) {
@@ -38,36 +38,26 @@ export default Vue.extend({
3838 methods : {
3939 add < P , R > ( component : RegularComponent , params : P , unmountDelay ?: number ) : Promise < R > {
4040 return new Promise < R > ( ( resolve , reject ) => {
41- this . dialogsData = new Map ( [
42- ...this . dialogsData ,
43- [
44- // eslint-disable-next-line symbol-description
45- Symbol ( ) ,
46- {
47- component,
48- params,
49- promiseResolve : resolve ,
50- promiseReject : reject ,
51- unmountDelay,
52- } ,
53- ] ,
54- ] ) ;
41+ // eslint-disable-next-line symbol-description
42+ this . $set ( this . dialogsData , Symbol ( ) as any /* symbol really can be used as a key */ , {
43+ component,
44+ params,
45+ promiseResolve : resolve ,
46+ promiseReject : reject ,
47+ unmountDelay,
48+ } ) ;
5549 } ) ;
5650 } ,
5751 resolve ( id : symbol , result : unknown , unmountDelay ?: number ) {
58- this . dialogsData . get ( id ) ? .promiseResolve ( result ) ;
52+ this . dialogsData [ id ] . promiseResolve ( result ) ;
5953 this . unmountDialog ( id , unmountDelay ) ;
6054 } ,
6155 reject ( id : symbol , error : unknown , unmountDelay ?: number ) {
62- this . dialogsData . get ( id ) ? .promiseReject ( error ) ;
56+ this . dialogsData [ id ] . promiseReject ( error ) ;
6357 this . unmountDialog ( id , unmountDelay ) ;
6458 } ,
6559 unmountDialog ( id : symbol , delay ?: number ) {
66- const unmount = ( ) => {
67- this . dialogsData = new Map (
68- [ ...this . dialogsData ] . filter ( ( [ key ] ) => key !== id ) ,
69- ) ;
70- } ;
60+ const unmount = ( ) => this . $delete ( this . dialogsData , id as any ) ;
7161 if ( delay ) {
7262 setTimeout ( unmount , delay ) ;
7363 } else if ( this . unmountDelay ) {
@@ -80,8 +70,9 @@ export default Vue.extend({
8070 render ( createElement ) : VNode {
8171 return createElement (
8272 'div' ,
83- [ ...this . dialogsData ] . map (
84- ( [ id , value ] ) => createElement ( value . component , {
73+ Object . getOwnPropertySymbols ( this . dialogsData ) . map ( ( id ) => {
74+ const value = this . dialogsData [ id ] ;
75+ return createElement ( value . component , {
8576 key : id as any ,
8677 props : {
8778 params : value . params ,
@@ -94,8 +85,8 @@ export default Vue.extend({
9485 this . reject ( id , error , unmountDelay || value . unmountDelay ) ;
9586 } ,
9687 } ,
97- } ) ,
98- ) ,
88+ } ) ;
89+ } ) ,
9990 ) ;
10091 } ,
10192} ) ;
0 commit comments