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

TypeError when calling Array.prototype.find on HTMLAllCollection #428

Closed
aaron-stripe opened this issue Nov 10, 2016 · 9 comments
Closed

Comments

@aaron-stripe
Copy link

aaron-stripe commented Nov 10, 2016

The shimmed version of Array.prototype.find raises a TypeError when called on an HTMLAllCollection.

This is happening in v54.0.2840.71 of Chrome.

Here is a codepen that reproduces this bug in Chrome: http://codepen.io/pifantastic/pen/vyLxGq

Array.prototype.find.call(document.all, (item, idx) => console.log)
// Uncaught TypeError: Cannot call method on [object HTMLAllCollection](…)

screenshot 2016-11-10 13 46 49

@ljharb
Copy link
Collaborator

ljharb commented Nov 10, 2016

document.all is HIGHLY deprecated, and should never be used - try document.querySelectorAll('*') instead, if you really want that.

document.all is a special case as the only falsy object in all of JS and browsers, and there's not a reliable way for me to detect it - but it's been a bad practice for over a decade to use it.

@aaron-stripe
Copy link
Author

@ljharb Yep. We don't actually use it. Apparently a lot of browser extensions do though :(

We reported this due to a big spike in errors in our error reporting service. I understand if you're not interested in fixing it at the es6-shim level. We can find a workaround on our side.

@ljharb
Copy link
Collaborator

ljharb commented Nov 10, 2016

@aaron-stripe i'd love to fix it if there's a proper way to do it, but document.all is a pretty horrifically bad thing to have explicit support for :-/

The codepen is helpful - can you point me to some libraries that are trying to pass document.all into Array.prototype.find? The latter is new enough that these libs should be PR-able to do the right thing instead.

@ljharb ljharb reopened this Nov 10, 2016
@aaron-stripe
Copy link
Author

@ljharb unfortunately I don't know what library is responsible. From our end we can't see much, and our best guess is that it's a browser extension that is doing something on each page load. I can tell you that we first saw it happening ~ Nov 9, 2016 6:37:08 PM UTC. I will definitely post more details if I can figure out how to get them.

@tzurbaev
Copy link

If someone interested, VueJS Devtools extension for Chrome causes this error too. But I don't think that a lot of @aaron-stripe users have devtools installed.

@aaron-stripe
Copy link
Author

aaron-stripe commented Nov 13, 2016

@tzurbaev amazing! The timing on this lines up pretty well, it's possible that VueJS Devtools is causing the issue I'm seeing. I just opened a PR with a fix.

@ljharb
Copy link
Collaborator

ljharb commented Nov 13, 2016

@aaron-stripe since that PR is merged, let's give it a few days to land. If the errors don't subside, I'll write an awful hack to make this work here.

@ljharb ljharb closed this as completed in bca93e7 Nov 15, 2016
@ljharb
Copy link
Collaborator

ljharb commented Nov 15, 2016

I ended up writing the awful hack. The next release will include this fix.

@aaron-stripe
Copy link
Author

@ljharb thanks :)

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