#870 closed enhancement (wontfix)
isElement
Reported by: | john | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | core | Version: | |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
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]
Change History (5)
comment:1 Changed 16 years ago by
Description: | modified (diff) |
---|
comment:2 Changed 16 years ago by
Type: | bug → enhancement |
---|
comment:3 Changed 16 years ago by
Description: | modified (diff) |
---|---|
need: | → Review |
Resolution: | → wontfix |
Status: | new → closed |
comment:4 Changed 11 years ago by
comment:5 Changed 11 years ago by
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.
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); };