Bug Tracker

Modify

Ticket #10791 (closed bug: wontfix)

Opened 2 years ago

Last modified 15 months ago

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 2 years 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

Possible solution for quickIs:

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

We'll look into it.

comment:2 Changed 2 years 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 2 years 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 22 months ago by dmethvin

  • Status changed from closed to reopened
  • Resolution fixed deleted
  • Milestone 1.7.1 deleted

comment:5 Changed 22 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

Last edited 17 months ago by gibson042 (previous) (diff)

comment:6 Changed 22 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.

Last edited 15 months ago by gibson042 (previous) (diff)

comment:7 Changed 17 months ago by gibson042

#13015 is a duplicate of this ticket.

comment:8 follow-up: ↓ 9 Changed 15 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 15 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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.