Ticket #10791 (closed bug: wontfix)
Delegated Events fail on SVG elements
| Reported by: | rodneyrehm | Owned by: | gibson042 |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | event | Version: | 1.7 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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
Change History
comment:1 Changed 18 months ago by timmywil
- Owner set to dmethvin
- Priority changed from undecided to low
- Status changed from new to assigned
- Component changed from unfiled to event
- Milestone changed from None to 1.7.1
comment:2 Changed 18 months ago by dmethvin
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?
comment:3 Changed 18 months ago by Dave Methvin
- Status changed from assigned to closed
- Resolution set to fixed
Fix #10791. SVG clamors for special treatment of its class names.
Changeset: 780c59b89d3b7fb9bcc480aa3173693a9d633853
comment:4 Changed 11 months ago by dmethvin
- Status changed from closed to reopened
- Resolution fixed deleted
- Milestone 1.7.1 deleted
comment:5 Changed 11 months ago by gibson042
- Owner changed from dmethvin to gibson042
- Status changed from reopened to assigned
https://github.com/jquery/jquery/pull/857
Please use "[class~='foo']" with SVG elements
Edit: corrected selector
comment:6 Changed 11 months ago by dmethvin
- Status changed from assigned to closed
- Resolution set to wontfix
For the browsers where .foo wouldn't work, [class~=foo] should work.
comment:8 follow-up: ↓ 9 Changed 4 months ago by BiAiB
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")
comment:9 in reply to: ↑ 8 Changed 4 months ago by gibson042
Replying to 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/
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Possible solution for quickIs:
We'll look into it.