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

Array.find not working in all cases #420

Open
belugabob opened this issue Jul 15, 2016 · 6 comments
Open

Array.find not working in all cases #420

belugabob opened this issue Jul 15, 2016 · 6 comments

Comments

@belugabob
Copy link

belugabob commented Jul 15, 2016

I'm using es6-shim to polyfill Array.find for broswers that don't support it.
The issue that I'm having is that some arrays are not being polyfilled.
Further investigation reveals that arrays which I create in my own code are being polyfilled, but arrays withing object structures being sent to the browser via signalr (2.2.0) are not.
Is this a known issue, or am I being stupid, and misunderstanding something?

Internet Explorer 11.0.9600.18314 - update 11.0.31
es6-shim 0.35.0

@ljharb
Copy link
Collaborator

ljharb commented Jul 15, 2016

@belugabob can you explain "arrays with object structures"? I'm not familiar with signalr, but if you try Array.isArray(foo), then unless it returns true, it's not actually an array.

@belugabob
Copy link
Author

Forgive my typo - should read "arrays within object structures"

Off the top of my head, as I'm not at my computer, and abbreviated for simplicity...

{
Category: "Staff",
Entrants: [ { Name: "Fred", Id: 1},{ Name: "Bert", Id: 2}],
}

SignalR is a server to browser communication library which effectively"pushes" data to the browser. I suspect that my issue is related to the way that SignalR deserializes the JSON payload
When I get back to my desk, I'll investigate the Array.isArray situation, but I'm pretty sure that 'Entrants' was showing up as an Array, in the browser debugger

@ljharb
Copy link
Collaborator

ljharb commented Jul 15, 2016

It is possible, if SignalR is creating those arrays in a different realm (like an iframe, or a web worker) then they'd have an un-shimmed Array.prototype. If so, you could use Array.prototype.find.call instead, or, also run the es6-shim in the realm they're using.

@belugabob
Copy link
Author

Ok, that sounds possible - will investigate further

@cvanleeuwen
Copy link

I've the encountered this exact same issue using SignalR 2.2.1.

But this seems to be more of an SignalR issue rather than es6-shim correct?

@ljharb
Copy link
Collaborator

ljharb commented Oct 5, 2016

@cvanleeuwen yes, that seems to be the case. An issue should be filed on SignalR, and this one closed.

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

No branches or pull requests

3 participants