On Nov 12, 2015, at 6:58 AM, Alex Harui <aha...@adobe.com> wrote: > > > On 11/11/15, 4:11 PM, "Harbs" <harbs.li...@gmail.com> wrote: > >> A little update on my progress: >> >> XMLList turned out to be easy with the exception of length(). Most of the >> functionality is being offloaded to XML. > > I don’t remember what happens to the base XML if you add or remove items > to an XMLList,
Oh! This brings up an important point! It’s possible to remove XML elements using the global delete keyword so “delete myXML.Harbs” or “delete myXML.Harbs[0]” would get rid of me. I have no idea how to handle that on the JS side. > but it may not be necessary to subclass Array to get [] > indexing. And by not subclassing Array, you won’t expose the Array > methods that don’t exist on XMLList (push, pop, slice, etc). > > One alternate approach is to use Object.defineProperties to define > properties named “0”, “1”, etc. You know how many properties you have to > define since you know the length. And then you’ll be able to define a > length() method without a collision with Array. Of course, I could be > missing something. Nice idea, but I don’t think that’s going to work. You can add items to an XMLList using bracket notation as well. So there’s no way to know ahead of time how many indexes you’re going to need. I personally don’t see the problem with having Array functions on XMLList. It’s a very array-like object and I so no damage in having it behave completely like an array. Is it a problem to map length() to length in FalconJX? > >> >> XML is turning out to be more challenging than I originally thought. It >> turns out that there’s a pretty big difference between a Document and a >> Node in HTML while in ActionScript there’s not much difference with the >> exception of having a parent and an index. At this point, I think I’m >> only using DOMParser to convert the XML to a walkable tree, but I think >> it needs to be objects rather than a Document under the hood. > > Right, but wouldn’t the objects be instances of your new XML class? Yup. I’m just going to have to do all the heavy lifting myself without off-loading it to Document.