@@ -30,20 +30,6 @@ define([
30
30
url . setBaseUrl ( window . BASE_URL ) ;
31
31
options . sectionLoadUrl = url . build ( 'customer/section/load' ) ;
32
32
33
- function initStorage ( ) {
34
- if ( options . cookieLifeTime !== 'undefined' ) {
35
- $ . cookieStorage . setConf ( {
36
- path : '/' ,
37
- expires : new Date ( Date . now ( ) + parseInt ( options . cookieLifeTime , 10 ) * 1000 )
38
- } ) ;
39
- storage = $ . initNamespaceStorage ( 'mage-cache-storage' ) . localStorage ;
40
- storageInvalidation = $ . initNamespaceStorage ( 'mage-cache-storage-section-invalidation' ) . localStorage ;
41
- }
42
- }
43
-
44
- // Initialize storage with default parameters to prevent JS errors while component still not initialized
45
- initStorage ( ) ;
46
-
47
33
/**
48
34
* @param {Object } invalidateOptions
49
35
*/
@@ -241,7 +227,14 @@ define([
241
227
/**
242
228
* Storage init
243
229
*/
244
- initStorage : initStorage ,
230
+ initStorage : function ( ) {
231
+ $ . cookieStorage . setConf ( {
232
+ path : '/' ,
233
+ expires : new Date ( Date . now ( ) + parseInt ( options . cookieLifeTime , 10 ) * 1000 )
234
+ } ) ;
235
+ storage = $ . initNamespaceStorage ( 'mage-cache-storage' ) . localStorage ;
236
+ storageInvalidation = $ . initNamespaceStorage ( 'mage-cache-storage-section-invalidation' ) . localStorage ;
237
+ } ,
245
238
246
239
/**
247
240
* Retrieve the list of sections that has expired since last page reload.
@@ -269,7 +262,9 @@ define([
269
262
270
263
// process sections that can expire due to storage information inconsistency
271
264
_ . each ( cookieSectionTimestamps , function ( cookieSectionTimestamp , sectionName ) {
272
- sectionData = storage . get ( sectionName ) ;
265
+ if ( storage !== undefined ) {
266
+ sectionData = storage . get ( sectionName ) ;
267
+ }
273
268
274
269
if ( typeof sectionData === 'undefined' ||
275
270
typeof sectionData === 'object' &&
@@ -406,10 +401,6 @@ define([
406
401
*/
407
402
'Magento_Customer/js/customer-data' : function ( settings ) {
408
403
options = settings ;
409
-
410
- // re-init storage with a new settings
411
- customerData . initStorage ( ) ;
412
-
413
404
customerData . initStorage ( ) ;
414
405
invalidateCacheBySessionTimeOut ( settings ) ;
415
406
invalidateCacheByCloseCookieSession ( ) ;
0 commit comments