Side navigation
#2787 closed bug (fixed)
Opened May 05, 2008 05:16AM UTC
Closed May 06, 2008 02:31AM UTC
Attribute filter ignores elements not appended to DOM tree
Reported by: | arrix | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.2.4 |
Component: | core | Version: | 1.2.3 |
Keywords: | selector | Cc: | |
Blocked by: | Blocking: |
Description
Attribute filter ([attribute=value]) cannot select elements not appended to the document tree.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>1.2.4a Rev: 5390</title> <script type="text/javascript" src="../jquery/dist/jquery.js"></script> <script type="text/javascript"> $(function() { var f = $('<form><input type="button" name="ok" value="OK"/></form>'); alert(f.find('input[name="ok"]').length); //0 but should be 1 f.appendTo(document.body); alert(f.find('input[name="ok"]').length); //1 }); </script> </head> <body> </body> </html>
1.2.4a Rev: 5390
It's in selector.js jQuery.filter (near line 338)
of course document.getElementsByName only returns elements in the document tree.