Bug Tracker

Ticket #221 (closed bug: fixed)

Opened 2 years ago

Last modified 1 year ago

filter seemingly not operating correctly

Reported by: yardley@… Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.0 Component: core
Version: 1.0 Keywords: filter
Cc: Needs:

Description

based on http://jquery.com/docs/Base/Expression/CSS/

and for test purposes, operating on http://jquery.com/

the following happens with filter (works on class and not on other attributes like id):

>>> $('div')
[<div class="head">,<div class="wrap">,<div class="wrap2">,<div id="side">,<div id="body">,<div class="wiki" id="content">,<div class="wikipage">,<div id="searchable">,<div style="text-align: center;">,<div id="footer">,<div class="wrap2">,<div class="col">,<div class="col">,<div class="col">,<div class="col">]
>>> $('div').filter('[@id="side"]')
[<div id="side">]
>>> $('div').filter('[@id^="side"]')
z has no properties
jquery-latest.js (line 710)
>>> $('div').filter('[@class="wrap"]')
[<div class="wrap">]
>>> $('div').filter('[@class^="wrap"]')
[<div class="wrap">,<div class="wrap2">,<div class="wrap2">]

the offending code:

 // Build a custom macro to enclose it
 eval("f = function(a,i){" +
  ( m[1] == "@" ? "z=jQuery.attr(a,m[3]);" : "" ) +
    "return " + f + "}");

Attachments

Change History

Changed 2 years ago by anonymous

To explain more simply,

 $('[@id="foo"]).each(...)

works but

 $('[@id^="foo"]).each(...)

doesn't. The latter gives an "Error: z has no properties"

Changed 2 years ago by joern

  • status changed from new to closed
  • resolution set to fixed

Fixed in SVN.

Note: See TracTickets for help on using tickets.