Skip to main content

Bug Tracker

Side navigation

#10791 closed bug (wontfix)

Opened November 15, 2011 12:36PM UTC

Closed July 11, 2012 09:51PM UTC

Last modified January 22, 2013 05:56PM UTC

Delegated Events fail on SVG elements

Reported by: rodneyrehm Owned by: gibson042
Priority: low Milestone:
Component: event Version: 1.7
Keywords: Cc:
Blocked by: Blocking:
Description

Using delegated events on embedded SVG has an error regarding class selectors (possibly other selectors, too). This used to work with jQuery 1.6.4.

http://jsfiddle.net/rodneyrehm/ydmXA/ - working jQuery 1.6.4

http://jsfiddle.net/rodneyrehm/cm9Gv/ - failing jQuery 1.7

Attachments (0)
Change History (9)

Changed November 15, 2011 03:15PM UTC by timmywil comment:1

component: unfiledevent
milestone: None1.7.1
owner: → dmethvin
priority: undecidedlow
status: newassigned

Possible solution for quickIs:

m[3].test( elem.attributes.class )

We'll look into it.

Changed November 16, 2011 03:57AM UTC by dmethvin comment:2

To continue timmywil's line of thought:

http://jsfiddle.net/dmethvin/mzjEY/

el.attributes['class'].value seems to work all the way back to IE6; you'll need to comment out a few lines for it to run in IE6/7.

Unfortunately we probably need to check el.attributes && el.attributes['class'] && el.attributes['class'].value to be safe.

Did I mention I hate SVG?

Changed November 16, 2011 03:36PM UTC by Dave Methvin comment:3

resolution: → fixed
status: assignedclosed

Fix #10791. SVG clamors for special treatment of its class names.

Changeset: 780c59b89d3b7fb9bcc480aa3173693a9d633853

Changed July 11, 2012 07:57PM UTC by dmethvin comment:4

milestone: 1.7.1
resolution: fixed
status: closedreopened

Changed July 11, 2012 08:28PM UTC by gibson042 comment:5

_comment0: https://github.com/jquery/jquery/pull/857 \ \ Please use "[class=foo]" with SVG elements1342040675126321
_comment1: https://github.com/jquery/jquery/pull/857 \ \ Please use "[class='foo']" with SVG elements1354889705530708
owner: dmethvingibson042
status: reopenedassigned

https://github.com/jquery/jquery/pull/857

Please use "[class~='foo']" with SVG elements

Edit: corrected selector

Changed July 11, 2012 09:51PM UTC by gibson042 comment:6

_comment0: For the browsers where `.foo` wouldn't work, `[class=foo]` should work.1360353797245153
resolution: → wontfix
status: assignedclosed

For the browsers where .foo wouldn't work, [class~=foo] should work.

Changed December 07, 2012 02:12PM UTC by gibson042 comment:7

#13015 is a duplicate of this ticket.

Changed January 22, 2013 04:20PM UTC by BiAiB comment:8

just for those wondering like I did,

jQuery don't plan on fixing any issue related to SVG/XML/VML:

http://docs.jquery.com/Won%27t_Fix#SVG.2FXML.2FVML_Bugs

and the workaround ~= might be problematic is some cases ([class~='selected'] also matches class="unselected")

Changed January 22, 2013 05:56PM UTC by gibson042 comment:9

Replying to [comment:8 BiAiB]:

the workaround ~= might be problematic is some cases ([class~='selected'] also matches class="unselected")

No, ~= treats attribute values as space-separated lists and checks for an exact match.

http://www.w3.org/TR/CSS21/selector.html#pattern-matching

http://api.jquery.com/attribute-contains-word-selector

http://jsfiddle.net/cm9Gv/5/