- From: Jonas Sicking <jonas@sicking.cc>
- Date: Wed, 29 May 2013 20:34:17 -0700
- To: public-script-coord@w3.org, Arun Ranganathan <arun@mozilla.com>, Boris Zbarsky <bzbarsky@mit.edu>, Anne van Kesteren <annevk@annevk.nl>
- Message-ID: <CA+c2ei8_nvkB1grW=vkUXO0keptX9b=qrMjJ4TqNJqtyaQK+jw@mail.gmail.com>
Hi All, I've not kept up with all the latest around sequences in WebIDL, so forgive me if this is a resolved topic. Is there really a reason to keep FileList around as a type? There are two contexts where FileList is currently used: 1. In read-only situations. For example, in the drag'n'drop related APIs, we want to expose a list of files that the user dropped on a webpage. However ideally that list shouldn't be modifyable since the rest of the API which indicates what the user dragged is readonly. 2. In read-write situations. For the HTMLInputElement.files property, we should ideally permit doing something like "element.files = [blob1, blob2, blob3]". Ideally I would even want FileList as a separate type to go away and instead we'd only use normal JS Arrays. For 1 this seems to work fine. sequence<File> in WebIDL maps to a plain JS Array. Though we might want to return an array that is frozen so that multiple consumers couldn't interfere with one another. For 2 it's a bit trickier. We could define that the .files setter takes a sequence<Blob> and that the getter returns a different sequence<Blob>. I.e. myInputElement.files = myArray; myInputElement.files === myArray; // false There is a question of if we for 2 want things like myInputElement.files.push(new Blob(...)); to work. I.e. should you not just be able to set a new array, but also mutate the existing array. A tricky part is that the implementation needs to react to modifications to the array. At the very least it might need to update the UI of the element to show that a different set of files are attached to the element. I presume that the implementation could use Object.observe to detect when the array is modified and update its the UI in response? I.e. does Object.observe allow detecting arbitrary changes to an array, including both swapping out existing elements, as well as detect new elements being appended. If we can find good answers to these questions, then we should be able to get rid of list-classes like FileList. / Jonas
Received on Thursday, 30 May 2013 03:34:50 UTC