Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFilter Json.Decode.keyValuePairs with hasOwnProperty #768
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Dec 2, 2016
Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Dec 2, 2016
|
Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Dec 2, 2016
Contributor
+1, this is stupid JS garbage. Whitespace diff is instructive: append ?w=1 to the URL.
|
+1, this is stupid JS garbage. Whitespace diff is instructive: append |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rtfeldman
Dec 5, 2016
Member
Yep, this seems like the right thing to do here.
Screenshot of the diff without whitespace, per Max's comment:
|
Yep, this seems like the right thing to do here. Screenshot of the diff without whitespace, per Max's comment: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lsjroberts
Dec 6, 2016
Just rebasing from master to get the elm-test fixes and put the brace on a new line.
lsjroberts
commented
Dec 6, 2016
|
Just rebasing from master to get the |
evancz
changed the title from
Fix key value pairs to filter out non-own properties
to
Filter Json.Decode.keyValuePairs with hasOwnProperty
Mar 26, 2017
evancz
closed this
in
4158c7f
Jul 9, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Jul 9, 2017
Member
Thank you for the suggestion! The code moved around and changed a bit for 0.19 so I added the check myself.
|
Thank you for the suggestion! The code moved around and changed a bit for 0.19 so I added the check myself. |

lsjroberts commentedDec 2, 2016
If I wish to decode
target.childNodes[...].textContentI would expect the following to work:However, since
target.childNodesis an instance ofNodeListthis silently fails due to it having some inherited props, such as.length,.entriesetc, in addition to the expected indices.(Unless I'm missing something) the solution to this in Elm is:
This is rather convoluted, and indeed since no errors were thrown I had to step debugger through Elm itself to discover the cause. I believe doing a
.hasOwnPropertycheck would solve this for the common use case where the expected values are all of the same type.(The
List.reverseis a possibly unrelated curiosity, but does appear to be required in all my tests).(This may be worth a separate issue, but using
Decode.listinstead ofDecode.keyValuePairsalso resulted in a silent error).I can provide a full demo app if required.