Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undeclared javascript variables #22879

Merged
merged 1 commit into from
Mar 3, 2022

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Mar 3, 2022

Overview

Fixes veda-consulting-company/uk.co.vedaconsulting.mosaico#494

Before

Javascript errors caused some functionality to break, notably the Mosaico Recipients widget.

After

All better.

Technical Details

These variables need to be declared with the var keyword, or it crashes some browsers.

@MegaphoneJon noted that you have to disable debug mode to see the error manifest. It probably depends on your browser too. My theory about that is that in debug mode, each js file is served separately, and these files do not include the "use strict"; directive, but without debug mode the files all get cobbled together into one big js file, so if one of those said "use strict";` it would affect how the code in this file is treated.

These variables need to be declared with the `var` keyword, or it crashes some browsers.
@civibot
Copy link

civibot bot commented Mar 3, 2022

(Standard links)

@civibot civibot bot added the master label Mar 3, 2022
@colemanw colemanw changed the title Fix undefined javascript variables Fix undeclared javascript variables Mar 3, 2022
Comment on lines +101 to 103
var more = data.more_results;

if (more && !data.more_results) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe out-of-scope for this PR, but I just did a double take at the logic of these 2 lines. What the 💩???
😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes it: #23188

@colemanw colemanw changed the base branch from master to 5.47 March 3, 2022 13:27
@civibot civibot bot added 5.47 and removed master labels Mar 3, 2022
@seamuslee001
Copy link
Contributor

This seems fine to me

@seamuslee001 seamuslee001 merged commit a825a35 into civicrm:5.47 Mar 3, 2022
@seamuslee001 seamuslee001 deleted the fixUndefinedVars branch March 3, 2022 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angular Errors on New Mailing with v2.9.1645644008 and Civi Core 5.46.2
2 participants