Closed rrees closed 9 years ago
:+1:
One never gets back from Immutableland :-)
@rrees Maybe a bit too late, but I checked the implementation of the Immutable.List constructor and figured that you can actually just use var types = Immutable.List(event.clipboardData.types);
It's possible because to create a List it goes through a sequence of checks, one of which is isArrayLike
. In all the browsers our type thingy is an array like as far as Immutable concerned (it has a length method on its prototype) so Immutable calls the ArraySeq constructor as a result. That doesn't solve our problem on it's own because we just basically packed our array-like into a ArraySeq container. However, the only method we need is .includes
which doesn't care about the kind of iterable you feed it as long as it can iterate over it using a for loop.
I didn't think about it because I completely forgot that we already have a dependency on Immutable.
@alexeygolev Thanks for looking for this. I tried this but it failed for me on Firefox because the DOMStringList couldn't be tickled into the a Seq. If you're certain it works I would much prefer to use this as the solution.
@rrees weird... it shouldn't even depend on the FF version. Does this work for you in FF? https://jsfiddle.net/heopbyo3/4/
That does appear to work, how odd that I thought it didn't. I'll try and release this (nicer) version soon.
@alexeygolev unless you want to put in a PR?
@rrees will do it now
Combines @alexygolev 's advice with my own desire to hit everything with the Immutable hammer.
Should finally solve #401
An illustration of the unification: https://jsfiddle.net/heopbyo3/3/