Bug Tracker

Ticket #185 (closed bug: fixed)

Opened 8 years ago

Last modified 8 years ago

`]` breaks selectors

Reported by: anonymous Owned by:
Priority: major Milestone: 1.0
Component: core Version: 1.0
Keywords: ] selector Cc:
Blocking: Blocked by:

Description

I want to select input files by their name, but ] seems to break jquery - no errors are thrown in my JS-console (ff). I use the latest svn co.

Here are some examples which break jquery:

    $("input[@name='foobar[]']").hide();
    $("input[@name='foobar[foobar]']").hide();

This does seem to work though:

    $("input[@name^='foobar['").hide();
    $("input[@name^='foobar[foobar'").hide();

The HTML would be:

    <input name="foobar[]" />
    <input name="foobar[foobar]" />

Hope you can fix this!

Change History

comment:1 Changed 8 years ago by mail@…

  • Status changed from new to closed
  • Resolution set to fixed

So, I think I found the bug myself:

Line 1779:

    .replace( 'Q', " *'?"?([^'"]*?)'?"? *" ), "i" );

This should be something like this:

    .replace( 'Q', " *('|"|)([^'"]*?)4 *" ), "i" );

But the backreference (4) only works for parse[1] obviously! Also now one more key exists in m - so we'll have to reorganize it.

Here is my fix:  http://nopaste.php-q.net/238335

What I did: # removed arrays from jQuery.parse (I think we don't need those any longer) # count ( and S for the number of the backreference # changed Q regex # changed reorganizing of m

*Please test this* - it works for me, as far as I can tell!

comment:2 Changed 8 years ago by john

  • Status changed from closed to reopened
  • Resolution fixed deleted

comment:3 Changed 8 years ago by mail@…

Woha, I found the test suite and have to say: Awesome! Debugging made easy. One more plus for jquery!

I changed two bugs within my fix, now all tests are passed.

 http://nopaste.php-q.net/238501

Here is a suggestion for a test:

give input#hidden2 name="foo[bar]" t( "Grouped Form Elements", "input[@name='foo[bar]']", hidden2? );

comment:4 Changed 8 years ago by mail@…

Sorry, messed up the suggestion:

give input#hidden2 name="foo[bar]"
t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );

comment:5 Changed 8 years ago by joern

  • Version changed from 1.0b1 to 1.0

Added test to SVN, it fails in FF and dies in IE

comment:6 Changed 8 years ago by mail@…

It fails with the old jquery filter, or? Not with my fix?

comment:7 Changed 8 years ago by mail@…

 http://nopaste.php-q.net/238509

That is an updated version (I forgot to remove a debug msg)

"it fails in FF and dies in IE" - try it with my fix - it should work.

comment:8 Changed 8 years ago by joern

  • Status changed from reopened to closed
  • Resolution set to fixed

Added proposed fix to SVN, tested on FF 1.5.0.6, IE6 and Opera 9.01 works fine.

Note: See TracTickets for help on using tickets.