2
2
* Copyright © Magento, Inc. All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
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
+
5
52
define ( 'buildTools' , [
6
53
] , function ( ) {
7
54
'use strict' ;
8
55
9
- var storage = window . localStorage ,
56
+ var storage ,
10
57
storeName = 'buildDisabled' ;
11
58
59
+ try {
60
+ storage = window . localStorage ;
61
+ } catch ( e ) {
62
+ storage = storageShim ;
63
+ }
64
+
12
65
return {
13
66
isEnabled : storage . getItem ( storeName ) === null ,
14
67
@@ -70,9 +123,15 @@ define('statistician', [
70
123
] , function ( ) {
71
124
'use strict' ;
72
125
73
- var storage = window . localStorage ,
126
+ var storage ,
74
127
stringify = JSON . stringify . bind ( JSON ) ;
75
128
129
+ try {
130
+ storage = window . localStorage ;
131
+ } catch ( e ) {
132
+ storage = storageShim ;
133
+ }
134
+
76
135
/**
77
136
* Removes duplicated entries of array, returning new one.
78
137
*
@@ -326,4 +385,4 @@ define('text', [
326
385
} ;
327
386
328
387
return text ;
329
- } ) ;
388
+ } ) ;
0 commit comments