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

Uncaught TypeError: Cannot read property 'addEventListener' of undefined #1076

Closed
bedrosenator opened this issue Mar 16, 2018 · 8 comments
Closed

Comments

@bedrosenator
Copy link

bedrosenator commented Mar 16, 2018

It happens after transition to a page, where power-select was rendered before.
Uncaught TypeError: Cannot read property 'addEventListener' of undefined
at Class.stopTextSelectionUntilMouseup (trigger.js:206)
at Class.handleMouseDown (trigger.js:114)
at Class.send (ember.debug.js:43117)
at Class.superWrapper [as send] (ember.debug.js:42834)
at HTMLDivElement. (trigger.js:223)

@mehanika
Copy link
Contributor

I'm having the same issue, Im using ember-power-select inside a component (could be that the issue?).
What I've see is that self.document is undefined and it crash when calls addEventListener

stopTextSelectionUntilMouseup: function stopTextSelectionUntilMouseup() {
      self.document.addEventListener('mouseup', this._mouseupHandler, true);
      self.document.body.classList.add('ember-basic-dropdown-text-select-disabled');
    },

@cibernox
Copy link
Owner

weird. Could make a PR removing the self. part? At the end, it's just redundant. document is a global that should be everywhere (except fastboot obviously)

@mehanika
Copy link
Contributor

mehanika commented Apr 20, 2018

@cibernox Is there any reason for using self.document or self.window?

@cibernox
Copy link
Owner

Honestly, no.
I think that at some point in the past I setup a linter that disallowed any global, even things like window and document so I added self. to make it happy.

@mehanika
Copy link
Contributor

I've created the first pull request to ember-basic-dropdown, given that the error occurs in trigger.js #402

@cibernox
Copy link
Owner

@mehanika I've published a new beta of EBD. Since the dependency of EPS in EBD is ^, if you update your dependencies you should get the new version.

Let me know of the bug seems fixed and I'll close this.

@mehanika
Copy link
Contributor

@cibernox Well, all the errors related to trigger.js are fixed now. But EPS also uses self.window and self.document and I get the following errors:

ember.debug.js:26513 TypeError: Cannot read property 'querySelector' of undefined
    at Class.focusInput (before-options.js:44)
    at Class.didInsertElement (before-options.js:17)
    at Class.superWrapper [as didInsertElement] (ember.debug.js:45374)
    at Class.trigger (ember.debug.js:47407)
    at Class.superWrapper [as trigger] (ember.debug.js:45374)
    at CurlyComponentManager.didCreate (ember.debug.js:19505)
    at Transaction.commit (ember.debug.js:6252)
    at Environment.commit (ember.debug.js:6427)
    at Environment.commit (ember.debug.js:16526)
    at InteractiveRenderer._renderRoots (ember.debug.js:18805)

I will create a pull request for removing self.window and self.document from EPS.

@mehanika
Copy link
Contributor

mehanika commented Apr 27, 2018

After changing the log the self was added again on EBD, as you can see in this commit 930d2ea @cibernox . So it won't work yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants