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

JS error: Uncaught TypeError: Cannot set property 'popups' of undefined #635

Closed
rkaiser0324 opened this issue Jan 24, 2019 · 3 comments
Closed
Labels
Milestone

Comments

@rkaiser0324
Copy link

Version tagged 1.7.30. Latest version of Chrome, 71.0.3578.98.

This is due to late_localize_scripts() - currently you have

echo 'window.pum_vars.popups = window.pum_popups;';

Shouldn't it be

echo 'window.pum_vars = {}; window.pum_vars.popups = window.pum_popups;';

Doesn't seem to affect popup display though.

@danieliser
Copy link
Member

danieliser commented Jan 25, 2019

@rkaiser0324 - Never seen this before in support, so unlikely its caused by the code on our end. That said the short answer, no it wouldn't be.

If you read the if statement above that line it says, if the script hasn't already been rendered, localize it the normal way, if it has already been rendered assign a global variable (same as localizing), then clone that variable into the global pum_vars object.

Since the cloning into the object only occurs if the pum-site-scripts are already loaded, that variable already exists, if we made the change you suggest we would overwrite all the variables already declared.

IE this only runs if the window.pum_vars is already on the page in the first place.

The only reason you would get that error is if your assets were not loading the normal way, IE are you using an optimization plugin that is combining them or moving them from footer to head etc. If so its telling WP its loaded, but not rendering it until after our code there gets rendered.

In any case haven't seen any other reports of this in the forums or support, so were gonna have to treat it as a localized conflict which we can try to debug.

That said you could change it to this which sets window.pum_vars to itself if it already exists, IE a sanity check.

echo 'window.pum_vars = window.pum_vars || {}; window.pum_vars.popups = window.pum_popups;';

Also you could probably just comment it out as well as its only used for some of our older extensions to keep them compatible.

@rkaiser0324
Copy link
Author

@danieliser you were absolutely correct - this was caused by a minification plugin, namely BWP-Minify. Bypassing it avoids this JS error. Thanks for the explanation.

@danieliser
Copy link
Member

Gonna add the change above just in case.

@danieliser danieliser reopened this Jan 25, 2019
@fpcorso fpcorso added this to the v1.12 milestone Jun 5, 2020
@fpcorso fpcorso modified the milestones: v1.12, v1.13 Jul 10, 2020
@fpcorso fpcorso modified the milestones: v1.13, v1.14 Sep 17, 2020
@fpcorso fpcorso modified the milestones: v1.14, v1.15 Nov 30, 2020
@fpcorso fpcorso closed this as completed Dec 28, 2020
@fpcorso fpcorso mentioned this issue Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants