json icon indicating copy to clipboard operation
json copied to clipboard

Make HTMLCollection and NodeList valid array types

Open decioferreira opened this issue 4 years ago • 2 comments

SSCCE: https://ellie-app.com/8zCdXgf99qCa1

On the SSCCE above I would expect the decoders for both childNodes (NodeList) and children (HTMLCollection) to decode correctly to a list - this is similar to how it currently handles FileList.

Found this issue when trying to implement a flexible data table, similar to the one shown here: https://adamlynch.com/flexible-data-tables-with-css-grid/#resizing-columns-with-grid

This is similar to #9.

decioferreira avatar Apr 13 '20 11:04 decioferreira

as mentioned on a conversation on elm-slack about this issue, a known workaround is to use https://package.elm-lang.org/packages/debois/elm-dom/latest/DOM#childNodes or to adapt it to our needs

decioferreira avatar Apr 13 '20 12:04 decioferreira

I create an Ellie which logs the fail outputs of the decoders, to make it clearer what this Ellie is testing.

https://ellie-app.com/gFrTm87Fz6wa1

rupertlssmith avatar Feb 11 '22 15:02 rupertlssmith

Does this patch fix both of the decoders in the Ellie?

rupertlssmith avatar Feb 11 '22 15:02 rupertlssmith

Out of the lines added in this patch, which line fixes which decoder in the Ellie?

|| (typeof FileList !== 'undefined' && value instanceof FileList)
|| (typeof HTMLCollection !== 'undefined' && value instanceof HTMLCollection)
|| (typeof NodeList !== 'undefined' && value instanceof NodeList);

And am I right in thinking that the Ellie does not test the FileList one? Is there some code to test that?

rupertlssmith avatar Feb 11 '22 15:02 rupertlssmith

Should the FileList one go in a separate PR? Since it is specific to working with file lists, and the other 2 are standard DOM traversal?

rupertlssmith avatar Feb 11 '22 15:02 rupertlssmith