Bug Tracker

Opened 7 years ago

Closed 6 years ago

#13141 closed bug (invalid)

customizing slectors

Reported by: lepelerin@… Owned by: lepelerin@…
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>

Change History (3)

comment:1 Changed 7 years ago by anonymous

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);

comment:2 Changed 7 years ago by dmethvin

Owner: set to lepelerin@…
Status: newpending

Please provide a a test case in jsfiddle.net.

comment:3 Changed 6 years ago by trac-o-bot

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!

Note: See TracTickets for help on using tickets.