Let me try this again
The crash occurs when a *property which is not part of a NodeList
interface* (i.e. "item", "length" or any numeric one) is being accessed
on a NodeList object *which contains textnode elements* and *is not part
of a document*:
typeof el.childNodes.item; // "function"
typeof el.childNodes.length; // "number"
typeof el.childNodes[0]; // "object"
el.childNodes[999]; // null
typeof el.childNodes.foo; // boom!
Correction: is *not* part of the DOM.
Actually, it's the other way around. When an element is inserted in a
document, the crash does not occur. Thanks for catching this, I haven't
noticed it first time.
Right! Crash occurs when the node is *not* part of the dom.
I did confirm that crash, using your testcase, on my Mac,
using Safari 2.0.4.
Not sure about array-like objects (e.g. `arguments` object is not
"affected"). I only noticed this with NodeList's.
Right, but a method like jQuery makeArray, or the Prototype.js toArray
function is expected to be used with anything array-like, such as a
NodeList, but not limited to that (could be a string or arguments object)..
Method jQuery.makeArray "Turns anything into a true array."
Well, AIUI, both - `isHostObjectProperty` and `isRealObjectproperty`
(from David's lib) would fail as well.
The typeof operator is limited and the wording very weak for host
objects (implementation-dependent) and the implementations differ. The
known values for callable host objects, when passed to tyeof includes:
"object", "function", "unknown", and "string".
A long string of typeof checks adds some (possibly important) clutter.