-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Preconditions and environment
- Mage 2.4.4
Steps to reproduce
- Open the console on the Product Detail page and define
const data={}
in the console. - Try to navigate the image gallery and get the below error:
./lib/web/magnifier/magnifier.js 26-30 is causing an error depending on contexts
largeWrapper = options.largeWrapper || '.magnifier-preview',
$magnifierPreview = $(largeWrapper);
curThumb = null,
magnifierOptions = {
It errors out later in the script, saying I cannot redefine const data
. This is because the list of variables starting at curThumb
doesn't have specified what kind of var it is, thus living in global space.
So a fix would either be
// Comma instead of ;
$magnifierPreview = $(largeWrapper),
curThumb = null,
Or properly initiate the variables
$magnifierPreview = $(largeWrapper);
var curThumb = null,
Expected result
No JS errors
Actual result
JS breaks, product detail page image gallery is not functional anymore.
Additional information
I wouldn't know which solution is preferred which is why I just drop this as an issue with possible solutions provided. Additionally, it would be great to have proper JS linting set up, that doesn't allow global variable declaration like this.
As far as I can see, this has been an issue/unchanged for a few Magento version, it just got triggered by another module/js taking 'control' of the 'data' var-label.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Activity
m2-assistant commentedon Sep 26, 2022
Hi @vandijkstef. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:
Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x releaseFor more details, review the Magento Contributor Assistant documentation.
Add a comment to assign the issue:
@magento I am working on this
To learn more about issue processing workflow, refer to the Code Contributions.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
m2-assistant commentedon Sep 26, 2022
Hi @engcom-Delta. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇
1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears.2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself.3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.- If the issue is reproducible on
2.4-develop
branch, please, add the labelReproduced on 2.4.x
.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
5. Add label
Issue: Confirmed
once verification is complete.6. Make sure that automatic system confirms that report has been added to the backlog.
engcom-Delta commentedon Sep 26, 2022
Hi @vandijkstef,
Thank you for reporting and collaboration,
Can you please provide more detail on which context you are getting error.
Thanks.
vandijkstef commentedon Oct 4, 2022
Hi @engcom-Delta,
Sorry I missed your question for a bit. Basically I have another js-script running that is trying to set a variable
const data
. The variable initialisation of the magnifier script is interupted by the;
on the line containing$magnifierPreview = $(largeWrapper);
making every variable after it global, as it's not prefixed byvar|let|const
anymore.Here's an interesting thread about the subject
engcom-Hotel commentedon Dec 13, 2022
@magento give me 2.4-develop instance
magento-deployment-service commentedon Dec 13, 2022
Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.
m2-assistant commentedon Dec 13, 2022
Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇
1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is valid
appears.2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Description
label to the issue by yourself.3. Add
Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.4. Verify that the issue is reproducible on
2.4-develop
branchDetails
- Add the comment@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.- If the issue is reproducible on
2.4-develop
branch, please, add the labelReproduced on 2.4.x
.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
5. Add label
Issue: Confirmed
once verification is complete.6. Make sure that automatic system confirms that report has been added to the backlog.
magento-deployment-service commentedon Dec 13, 2022
Hi @engcom-Hotel, here is your Magento Instance: https://41efee41a835c031623b15b144cde72f.instances.magento-community.engineering
Admin access: https://41efee41a835c031623b15b144cde72f.instances.magento-community.engineering/admin_3918
Login: 96e5af72
Password: 100afafa9b1d
31 remaining items