#787 closed bug (fixed)
Array support in selector is broken
Reported by: | Fil | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.1 |
Component: | core | Version: | 1.1a |
Keywords: | array selector | Cc: | [email protected]… |
Blocked by: | Blocking: |
Description
Here's a test that shouldn't be broken
test("expressions - array", function() { expect(1); t( "Array Support", ["a.blog", "div"], ["mark","simon","main","foo"] ); });
Attachments (3)
Change History (8)
Changed 16 years ago by
Changed 16 years ago by
Attachment: | 787.2.patch added |
---|
test and fix for this bug ; .substring() is also used for speed
Changed 16 years ago by
Attachment: | 787.patch.txt added |
---|
test and fix for this bug ; .substring() is also used for speed
comment:1 Changed 16 years ago by
trac doesn't let me attach the patch, so here it is (ugly)
Index: src/selector/selector.js =================================================================== --- src/selector/selector.js (revision 1016) +++ src/selector/selector.js (working copy) @@ -297,6 +297,10 @@ }, filter: function(t,r,not) { + // Support for array selectors + if ( typeof t == 'object' ) + t = t.join(','); + // Look for common filter expressions while ( t && /^[a-z[({<*:.#]/i.test(t) ) { @@ -312,13 +316,13 @@ var m = re.exec( t ); if ( m ) { + // Remove what we just matched + t = t.substring( m[0].length ); + // Re-organize the first match if ( jQuery.expr[ m[1] ]._resort ) m = jQuery.expr[ m[1] ]._resort( m ); - // Remove what we just matched - t = t.replace( re, "" ); - break; } } Index: src/selector/selectorTest.js =================================================================== --- src/selector/selectorTest.js (revision 1016) +++ src/selector/selectorTest.js (working copy) @@ -41,6 +41,12 @@ t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] ); }); +test("expressions - array", function() { + expect(1); + t( "Array Support", ["a.blog", "div"], ["mark","simon","main","foo"] ); +}); + + test("expressions - child and adjacent", function() { expect(14); t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
comment:2 Changed 16 years ago by
I don't know if the array selector is going to be of type "object" on all browsers. It works on FF2/Mac and Safari though.
Please note that I included a .substring() for speed.
comment:3 Changed 16 years ago by
Or, if the typeof test is costly, you could remove support for the array selector, the comma separated stuff is enough. But please mention it in the changelog :)
comment:4 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
We're removing support for the array selector in favor of the comma separated one. I mentioned this at the end of the recent blog post and there's support for it in the compatibility plugin. I'll be sure to re-announce it when its released.
I also added in your substring improvement.
test and fix for this bug ; .substring() is also used for speed