diff -Nuar a/lib/web/mage/requirejs/static.js b/lib/web/mage/requirejs/static.js index 237aa0c6a8a..ea005c37cbe 100644 --- a/lib/web/mage/requirejs/static.js +++ b/lib/web/mage/requirejs/static.js @@ -2,13 +2,66 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +var storageShim = { + _data: {}, + + /** + * Sets value of the specified item. + * + * @param {String} key - Key of the property. + * @param {*} value - Properties' value. + */ + setItem: function (key, value) { + 'use strict'; + + this._data[key] = value + ''; + }, + + /** + * Retrieves specified item. + * + * @param {String} key - Key of the property to be retrieved. + */ + getItem: function (key) { + 'use strict'; + + return this._data[key]; + }, + + /** + * Removes specified item. + * + * @param {String} key - Key of the property to be removed. + */ + removeItem: function (key) { + 'use strict'; + + delete this._data[key]; + }, + + /** + * Removes all items. + */ + clear: function () { + 'use strict'; + + this._data = {}; + } +}; + define('buildTools', [ ], function () { 'use strict'; - var storage = window.localStorage, + var storage, storeName = 'buildDisabled'; + try { + storage = window.localStorage; + } catch (e) { + storage = storageShim; + } + return { isEnabled: storage.getItem(storeName) === null, @@ -70,9 +123,15 @@ define('statistician', [ ], function () { 'use strict'; - var storage = window.localStorage, + var storage, stringify = JSON.stringify.bind(JSON); + try { + storage = window.localStorage; + } catch (e) { + storage = storageShim; + } + /** * Removes duplicated entries of array, returning new one. *