Description
Preconditions (*)
- Magento 2.4-develop
- It cannot be reproduced on clean Magento. An issue occurred only with incompatible code.
Steps to reproduce (*)
Open any page and take any action which force Magento to clean one section (In my case it was adding product to shopping cart from PDP)
Source code should contain sth like
customerData.reload('cart');
instead of
customerData.reload(['cart']);
Expected result (*)
The console log must be clear.
Actual result (*)
We faced with an issue in console:
customer-data.js:87 Uncaught Error: [object Object]
at Object. (customer-data.js:87)
at fire (jquery.js:3238)
at Object.fireWith [as rejectWith] (jquery.js:3368)
at done (jquery.js:9848)
at XMLHttpRequest.callback (jquery.js:10317)
What actually happens:
www/magento/vendor/magento/module-customer/view/frontend/web/js/section-config.js:61
Previous code:
/**
* @param {*} allSections
* @return {*}
*/
filterClientSideSections: function (allSections) {
if (Array.isArray(allSections)) {
return _.difference(allSections, clientSideSections);
}
return allSections;
},
Magento 2.3.5-p1 code:
/**
* Filters the list of given sections to the ones defined as client side.
* @param {Array} allSections - List of sections to check.
* @return {Array} - List of filtered sections.
*/
filterClientSideSections: function (allSections) {
return _.difference(_.toArray(allSections), clientSideSections);
},
When we pass into this function one element (string) JS parses as an array:
_.toArray(allSections)
(9) ["a", "u", "t", "h", "_", "d", "a", "t", "a"]
And of course cannot find such sections.
Upd 1.
Initially, your method accepted anything and we passed a string with a section name. Now your are accepting arrays only, but there no such verification in the method.
I suppose for backward compatibility you should return back isArray verification.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status