File tree Expand file tree Collapse file tree 1 file changed +3
-21
lines changed
src/bundle/Resources/public/js/scripts/core Expand file tree Collapse file tree 1 file changed +3
-21
lines changed Original file line number Diff line number Diff line change 77 this . eventName = config . eventName ;
88 }
99
10- stringifyData ( data ) {
11- try {
12- return JSON . stringify ( data ) ;
13- } catch ( error ) {
14- console . warn ( 'Error stringifying data' , error ) ;
15- }
16- }
17-
18- parseData ( data ) {
19- try {
20- return JSON . parse ( data ) ;
21- } catch ( error ) {
22- console . warn ( 'Error parsing data' , error ) ;
23-
24- return null ;
25- }
26- }
27-
2810 setItem ( data ) {
29- const stringifiedData = this . stringifyData ( data ) ;
11+ const stringifiedData = JSON . stringify ( data ) ;
3012
3113 global . localStorage . setItem ( this . key , stringifiedData ) ;
3214
3315 this . fireStorageChangeEvent ( stringifiedData ) ;
3416 }
3517
3618 getItem ( ) {
37- return this . parseData ( global . localStorage . getItem ( this . key ) ) ;
19+ return JSON . parse ( global . localStorage . getItem ( this . key ) ) ;
3820 }
3921
4022 fireStorageChangeEvent ( data ) {
4123 if ( this . eventName ) {
4224 const storageChangeEvent = new CustomEvent ( this . eventName , {
4325 cancelable : true ,
44- detail : { content : this . parseData ( data ) } ,
26+ detail : { content : JSON . parse ( data ) } ,
4527 } ) ;
4628
4729 doc . body . dispatchEvent ( storageChangeEvent ) ;
You can’t perform that action at this time.
0 commit comments