Right. I read that. This was what I was referring to in my last email. However, the Addition Operator is supposed to call [[Append]] and [[Append]] is supposed to assign the right side target object and target property to the left side object. So why doesn’t the original XML get effected?
On May 6, 2016, at 9:29 PM, Alex Harui <aha...@adobe.com> wrote: > I think I found the answer. I was thinking that > > list1 += list4, which is equivalent to > list1 = list1 + list4 > > would just use the [[Append]] operation. But that isn't true. Further > down in the spec (in 11.4) it actually addresses Addition operator. And > in there it says: > > > > > > > > > > "When both AdditiveExpression and MultiplicativeExpression > evaluate to either an XML object or an XMLList, the > addition operator starts by creating a new, empty XMLList > as the return value. If the left operand evaluates to an > XML object, it is added to the return value. If the left > operand evaluates to an XMLList, each XML property of the > XMLList is added to the return value in order. Likewise, > if the right operand evaluates to an XML object, it is added > to the return value. Otherwise, if it is an XMLList each > XML property of the XMLList is added to the return value in > order." > > > > > > Note the "new, empty XMLList". So, really, it is doing: > > > temp = new XMLList(); > temp.append(list1) > temp.append(list4); > list1 = temp; > > But when you run: > > xml2.a += list4, which is equivalent to > xml2.a = xml2.a + list4 > > It is really doing: > > temp = new XMLList(); > temp.append(xml2.a) > temp.append(list4); > xml2.a = temp; > > Temp doesn't have TargetObject or TargetProperty, and thus in the first > example, you can see that xml2 would never be affected. > > But in the second example, the reason it works is because temp is assigned > back to xml2.a with the Put operation. > > So, IMO, Flash is doing the right thing. Bizarre, but that's what the > spec says. And why all of your other examples did what they did. > > HTH, > -Alex > > On 5/6/16, 1:53 AM, "Harbs" <harbs.li...@gmail.com> wrote: > >> But, according to how I’m reading the spec, the following should work, >> but it doesn’t: >> >> list4 = new XMLList(); >> list4[0] = <a id="1"/>; >> list4[1] = <a id="2"/>; >> list4[2] = <a id="3"/>; >> >> list1 += list4 + xml2.z; >