22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5+ var storageShim = {
6+ _data : { } ,
7+
8+ /**
9+ * Sets value of the specified item.
10+ *
11+ * @param {String } key - Key of the property.
12+ * @param {* } value - Properties' value.
13+ */
14+ setItem : function ( key , value ) {
15+ 'use strict' ;
16+
17+ this . _data [ key ] = value + '' ;
18+ } ,
19+
20+ /**
21+ * Retrieves specified item.
22+ *
23+ * @param {String } key - Key of the property to be retrieved.
24+ */
25+ getItem : function ( key ) {
26+ 'use strict' ;
27+
28+ return this . _data [ key ] ;
29+ } ,
30+
31+ /**
32+ * Removes specified item.
33+ *
34+ * @param {String } key - Key of the property to be removed.
35+ */
36+ removeItem : function ( key ) {
37+ 'use strict' ;
38+
39+ delete this . _data [ key ] ;
40+ } ,
41+
42+ /**
43+ * Removes all items.
44+ */
45+ clear : function ( ) {
46+ 'use strict' ;
47+
48+ this . _data = { } ;
49+ }
50+ } ;
51+
552define ( 'buildTools' , [
653] , function ( ) {
754 'use strict' ;
855
9- var storage = window . localStorage ,
56+ var storage ,
1057 storeName = 'buildDisabled' ;
1158
59+ try {
60+ storage = window . localStorage ;
61+ } catch ( e ) {
62+ storage = storageShim ;
63+ }
64+
1265 return {
1366 isEnabled : storage . getItem ( storeName ) === null ,
1467
@@ -70,9 +123,15 @@ define('statistician', [
70123] , function ( ) {
71124 'use strict' ;
72125
73- var storage = window . localStorage ,
126+ var storage ,
74127 stringify = JSON . stringify . bind ( JSON ) ;
75128
129+ try {
130+ storage = window . localStorage ;
131+ } catch ( e ) {
132+ storage = storageShim ;
133+ }
134+
76135 /**
77136 * Removes duplicated entries of array, returning new one.
78137 *
@@ -326,4 +385,4 @@ define('text', [
326385 } ;
327386
328387 return text ;
329- } ) ;
388+ } ) ;
0 commit comments