Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 5 years ago

#2939 closed bug (fixed)

Selectors using style attribute broken

Reported by: remysharp Owned by: flesler
Priority: major Milestone: 1.3
Component: selector Version: 1.2.5
Keywords: selector style Cc:
Blocked by: Blocking:




Using the style attribute in the selector either returns the wrong number of results or throws exception.

Tested in FF2 and Safari (test above makes use of console.log).

Example selectors broken:

$(div[style]); returns total number of elements regardless of result

$(div[style="color"]); throws exception

Change History (8)

comment:1 Changed 9 years ago by remysharp

I think I've found a/the fix, but I've only been able to test on a Mac so far, Opera 9*, Safari 3, FF2 - not IE testing as yet, all browsers give the right result.

  • Opera gives almost the right results. It certainly counts the attribute correctly, but if you're pulling the style from <div style="color: red;" /> it translates it to "color: #ff0000" (sans semi-colon) which means it doesn't match some of the selectors - however colour aside, it fixes Opera.

File: src/selector.js rev: 5696

Change line 339 from (note intentional spaces in OR to prevent formatting):

if ( z == null | | /href|src|selected/.test(m[2]) )


if ( z == null | | /style|href|src|selected/.test(m[2]) )

Diff: http://codedumper.com/ocopo#9-10 (I couldn't paste the diff properly)

comment:2 Changed 9 years ago by flesler

Owner: set to flesler
Status: newassigned

Will try to check this asap.

comment:3 Changed 9 years ago by flesler

Component: coreselector

Could you recheck with 1.2.6 ?

comment:4 Changed 9 years ago by remysharp

Sorry, I thought I sent this check back - no it doesn't work with latest 1.2.6:


comment:5 Changed 9 years ago by flesler

need: ReviewCommit
Resolution: fixed
Status: assignedclosed

Fixed at [5795].

This made me realize of a possible optimization: #3194.

comment:6 Changed 6 years ago by sandy

Can you check in version 1.6.2. It does seem to work in this version.

comment:7 Changed 6 years ago by sandy

oops! sorry what i meant was It doesn't seem to work in this version.

comment:8 Changed 6 years ago by Rick Waldron

@sandy can you provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

Note: See TracTickets for help on using tickets.