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

don't initialize body scroll when in fastboot #187

Conversation

jamemackson
Copy link

@jamemackson jamemackson commented Nov 11, 2021

This PR addresses a " TypeError: window.addEventListener is not a function" error when using ember-mobile-menu under fastboot by preventing the body-scroll-lock library from initializing when running on the server where window isn't defined.

Error & start of stack trace...

There was an error running your app in fastboot. More info about the error: 
 TypeError: window.addEventListener is not a function
    at eval (webpack://__ember_auto_import__/./node_modules/body-scroll-lock/lib/bodyScrollLock.esm.js?:10:147)
    at Module../node_modules/body-scroll-lock/lib/bodyScrollLock.esm.js....

Fixes #186

@nickschot nickschot added the bug Something isn't working label Nov 11, 2021
@jamemackson
Copy link
Author

so turns out this doesn't yet work. Here's a minimal representation of the issue. https://github.com/jamemackson/ember-mobile-menu-fastboot-example

@nickschot any chance you can take a peek and give me a nudge in the right direction?

Comment on lines +17 to +20
fastboot = getOwner(this).lookup('service:fastboot');
get isFastBoot() {
return !!this.fastboot?.isFastBoot;
}
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
fastboot = getOwner(this).lookup('service:fastboot');
get isFastBoot() {
return !!this.fastboot?.isFastBoot;
}
get fastboot() {
return getOwner(this).lookup('service:fastboot');
}
get isFastBoot() {
return !!this.fastboot?.isFastBoot;
}

To be in line with the updated syntax on master.

@bakerac4
Copy link

bakerac4 commented Jan 2, 2024

@nickschot would it be possible to get this merged? Im also seeing this in fastboot.

@nickschot
Copy link
Owner

Closing, followup in #891 and #854

@nickschot nickschot closed this Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Getting window.addEventListener is not a function TypeError in FastBoot
3 participants