Skip to main content

Bug Tracker

Side navigation

#2939 closed bug (fixed)

Opened May 26, 2008 07:52PM UTC

Closed July 28, 2008 04:25PM UTC

Last modified March 14, 2012 10:16PM UTC

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:
Description

Demonstrations:

http://remysharp.com/demo/selector-issue.html

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

Attachments (0)
Change History (8)

Changed May 26, 2008 08:27PM UTC by remysharp comment:1

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

To:

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

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

Changed May 27, 2008 01:07AM UTC by flesler comment:2

owner: → flesler
status: newassigned

Will try to check this asap.

Changed June 11, 2008 10:40PM UTC by flesler comment:3

component: coreselector

Could you recheck with 1.2.6 ?

Changed June 26, 2008 11:42AM UTC by remysharp comment:4

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

http://remysharp.com/demo/selector-issue.html

Changed July 28, 2008 04:25PM UTC by flesler comment:5

need: ReviewCommit
resolution: → fixed
status: assignedclosed

Fixed at [5795].

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

Changed July 21, 2011 06:21AM UTC by sandy comment:6

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

Changed July 21, 2011 06:22AM UTC by sandy comment:7

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

Changed July 21, 2011 01:50PM UTC by rwaldron comment:8

@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.