Skip to main content

Bug Tracker

Side navigation

#870 closed enhancement (wontfix)

Opened January 23, 2007 05:20PM UTC

Closed July 15, 2007 03:02PM UTC

Last modified April 04, 2012 03:22PM UTC

isElement

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

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

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

Changed January 23, 2007 05:33PM UTC by john comment:1

description: Build a function that can test for isElement, some tests to consider:\ {{{\ document\ document.body\ document.body.childNodes\ document.body.firstChild // text node\ document.body.firstChild.nextSibling // Comment\ document.getElementsByTagName("form")[0]\ document.getElementsByTagName("form")[0].elements\ document.getElementsByTagName("object")[0]\ }}}Build a function that can test for isElement, some tests to consider:\ {{{\ window // should fail\ document // should fail\ document.body\ document.body.childNodes // should fail\ document.body.firstChild // fail, text node\ document.body.firstChild.nextSibling // fail, comment\ document.getElementsByTagName("form")[0]\ document.getElementsByTagName("form")[0].elements // fail, array\ document.getElementsByTagName("object")[0]\ }}}

Changed March 24, 2007 04:59PM UTC by john comment:2

type: bugenhancement

Changed July 15, 2007 03:02PM UTC by john comment:3

description: Build a function that can test for isElement, some tests to consider:\ {{{\ window // should fail\ document // should fail\ document.body\ document.body.childNodes // should fail\ document.body.firstChild // fail, text node\ document.body.firstChild.nextSibling // fail, comment\ document.getElementsByTagName("form")[0]\ document.getElementsByTagName("form")[0].elements // fail, array\ document.getElementsByTagName("object")[0]\ }}}Build a function that can test for isElement, some tests to consider: \ {{{ \ window // should fail \ document // should fail \ document.body \ document.body.childNodes // should fail \ document.body.firstChild // fail, text node \ document.body.firstChild.nextSibling // fail, comment \ document.getElementsByTagName("form")[0] \ document.getElementsByTagName("form")[0].elements // fail, array \ document.getElementsByTagName("object")[0] \ }}}
need: → Review
resolution: → wontfix
status: newclosed

Changed April 04, 2012 03:10PM UTC by anonymous comment:4

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); };

Changed April 04, 2012 03:22PM UTC by dmethvin comment:5

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.