Skip to main content

Bug Tracker

Side navigation

#13141 closed bug (invalid)

Opened January 01, 2013 01:52PM UTC

Closed January 21, 2013 09:05AM UTC

customizing slectors

Reported by: lepelerin@bluewin.ch Owned by: lepelerin@bluewin.ch
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.3
Keywords: Cc:
Blocked by: Blocking:
Description

dear support,

The very simple script below does not give same result !!

expected result: only even divs have orange background.

obtained result: all divs have orange background.

workaround: using jQuery-1.7.1.js solves the issue.

test env: Windows 8, IE10 and Chrome.

thanks and best regards,

alain


(function ($) {

$.expr[':'].myEven = function(elem,idx,meta,items){

return (idx % 2 === 0);

}

})(jQuery);

$(document).ready(function () { $('div:myEven').css('background-color', 'orange');

});


HTML CODE:

<h1> Custom selector </h1>

<div> Div01 </div>

<div> Div02 </div>

<div> Div03 </div>

<div> Div04 </div>

<div> Div05 </div>

<div> Div06 </div>

<div> Div07 </div>

<div> Div08 </div>

<div> Div09 </div>

<div> Div10 </div>

Attachments (0)
Change History (3)

Changed January 01, 2013 09:40PM UTC by anonymous comment:1

They changed Sizzle. The new syntax is:

(function ($) {
    // Both functions need to be marked as a pseudo, otherwise you don't have access to the indexes
    $.expr.pseudos.myEven = $.expr.createPseudo(function() {
        return $.expr.createPseudo(function(input, output){
            for(var i = 0; i < input.length; i += 2) {
                output.push(input[i]);
            }
        });
    });
})(jQuery);

Changed January 07, 2013 02:55AM UTC by dmethvin comment:2

owner: → lepelerin@bluewin.ch
status: newpending

Please provide a a test case in jsfiddle.net.

Changed January 21, 2013 09:05AM UTC by trac-o-bot comment:3

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!