Bug Tracker

Opened 16 years ago

Closed 16 years ago

Last modified 11 years ago

#870 closed enhancement (wontfix)


Reported by: john Owned by:
Priority: minor Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by john)

Build a function that can test for isElement, some tests to consider:

window // should fail
document // should fail
document.body.childNodes // should fail
document.body.firstChild // fail, text node
document.body.firstChild.nextSibling // fail, comment
document.getElementsByTagName("form")[0].elements // fail, array

Change History (5)

comment:1 Changed 16 years ago by john

Description: modified (diff)

comment:2 Changed 16 years ago by john

Type: bugenhancement

comment:3 Changed 16 years ago by john

Description: modified (diff)
need: Review
Resolution: wontfix
Status: newclosed

comment:4 Changed 11 years ago by anonymous

Why is this "wontfix"? After all there is $.isWindow and $.isXMLDoc. I'd implement it like this: $.isElement = function (e) { return !!(e && e.nodeType === 1); };

comment:5 Changed 11 years ago by dmethvin

If you profile a largeish jQuery app/site, you'll answer your own question. We test for something being a specific DOM nodeType a lot, often in tight loops. Even today you'll see that the cursed .isXMLDoc() comes up near the top of many profiles so we don't want another bottleneck. If we're not going to use it internally then it should be a plugin.

Note: See TracTickets for help on using tickets.