Subj : for each (var property in DOMCollectionObject) causes exception To : netscape.public.mozilla.dom,netscape.public.mozilla.jseng From : Martin Honnen Date : Sun Jan 30 2005 08:01 pm Intentionally crossposted to jseng and dom as it is an issue with the for each loop e4x adds to JavaScript but the error occurs with a loop on a dom object. The test case at tries both a for (var propertyName in collection) and a for each (var property in collection) on a DOM collection (result of getElementsByTagName). The for each loop enumerates two properties but then throws an error as follows in the JavaScript console: Error: uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: http://home.arcor.de/martin.honnen/mozillaBugs/e4x/foreachincollection.html :: showProperties :: line 17" data: no] If the order of properties enumerated by for in and for each in is the same then the error occurs for the property with name 'length'. Is the error a bug? On which component (JavaScript engine, DOM, or other (XPConnect)) should I file it? Error occurs with latest Mozilla 1.8b (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b) Gecko/20050130) but also with earlier builds. -- Martin Honnen http://JavaScript.FAQTs.com/ .