diff --git a/app/code/Magento/Catalog/view/base/requirejs-config.js b/app/code/Magento/Catalog/view/base/requirejs-config.js new file mode 100644 index 0000000000000..2fc0bbcb8c00d --- /dev/null +++ b/app/code/Magento/Catalog/view/base/requirejs-config.js @@ -0,0 +1,16 @@ +/** + * Copyright © Magento, Inc. All rights reserved. + * See COPYING.txt for license details. + */ + +var config = { + map: { + '*': { + priceBox: 'Magento_Catalog/js/price-box', + priceOptionDate: 'Magento_Catalog/js/price-option-date', + priceOptionFile: 'Magento_Catalog/js/price-option-file', + priceOptions: 'Magento_Catalog/js/price-options', + priceUtils: 'Magento_Catalog/js/price-utils' + } + } +}; diff --git a/app/code/Magento/Catalog/view/frontend/requirejs-config.js b/app/code/Magento/Catalog/view/frontend/requirejs-config.js index 55df18afeb024..3674d54340544 100644 --- a/app/code/Magento/Catalog/view/frontend/requirejs-config.js +++ b/app/code/Magento/Catalog/view/frontend/requirejs-config.js @@ -11,11 +11,6 @@ var config = { upsellProducts: 'Magento_Catalog/js/upsell-products', productListToolbarForm: 'Magento_Catalog/js/product/list/toolbar', catalogGallery: 'Magento_Catalog/js/gallery', - priceBox: 'Magento_Catalog/js/price-box', - priceOptionDate: 'Magento_Catalog/js/price-option-date', - priceOptionFile: 'Magento_Catalog/js/price-option-file', - priceOptions: 'Magento_Catalog/js/price-options', - priceUtils: 'Magento_Catalog/js/price-utils', catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart' } }, diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js similarity index 99% rename from app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js rename to app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js index 250141a942b10..894a4518f4de8 100644 --- a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js +++ b/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js @@ -296,6 +296,12 @@ define([ * @private */ _init: function () { + // Don't render the same set of swatches twice + if ($(this.element).attr('data-rendered')) { + return; + } + $(this.element).attr('data-rendered', true); + if (_.isEmpty(this.options.jsonConfig.images)) { this.options.useAjax = true; // creates debounced variant of _LoadProductMedia() diff --git a/lib/web/mage/requirejs/static.js b/lib/web/mage/requirejs/static.js index 898850cb2948b..ec66b5f1063e0 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. *