Side navigation
#13056 closed bug (patchwelcome)
Opened December 14, 2012 11:12AM UTC
Closed December 21, 2012 03:25PM UTC
Last modified July 25, 2013 02:20PM UTC
Bug on accessing class name in addClass and Remove class?
Reported by: | Michael van Engelshoven <michael@van-engelshoven.de> | Owned by: | Michael van Engelshoven <michael@van-engelshoven.de> |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | attributes | Version: | 1.8.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Hey!
While debugging the jquery-svg plugin from keith wood I found a difference how you hande class names in methods like addClass()
or removeClass()
and the class filter in the sizzle engine. In jquery core always elem.className
is used while sizzle uses elem.getAttribute('class')
if the className
attribute doesn't exist. Maybe this is a bug?!
Refernces:
https://github.com/jquery/sizzle/blob/1.8.2/sizzle.js#L600
https://github.com/jquery/jquery/blob/1.8.3/src/attributes.js#L57
Attachments (0)
Change History (8)
Changed December 14, 2012 02:07PM UTC by comment:1
owner: | → Michael van Engelshoven <michael@van-engelshoven.de> |
---|---|
status: | new → pending |
Changed December 17, 2012 12:08PM UTC by comment:2
status: | pending → new |
---|
I wasn't sure if this is a bug, but I created a few tests which fail in firefox:
The specification for Document Object Model HTML sais, className is only available for html documents. For xml we have to use getAttribute()
and setAttrbute()
.
Changed December 21, 2012 04:03AM UTC by comment:3
resolution: | → wontfix |
---|---|
status: | new → closed |
SVG documents are not DOM documents, we don't support them for many operations. We don't list them all in the docs because, SVG is on the wonfix list--it's just out of scope for jQuery.
Changed December 21, 2012 07:34AM UTC by comment:4
As you can see in my jsbin example, this is not a svg problem. The example is based on code from the jquery documentation… I just found this problem by fixing the svg plugin.
By the way: What makes you think that SVG is not a DOM document? Its a simple xml document, too.
Changed December 21, 2012 03:23PM UTC by comment:5
resolution: | wontfix |
---|---|
status: | closed → reopened |
It's an XML document. That's why you used $.parseXML()
to parse it. jQuery is primarily intended for use with HTML documents. Documents that are XML but not HTML often have different semantics and lack various interfaces. The class
attribute is not special in any way in that XML document, it could have been named kind
.
The basic traversing, selecting, and manipulating works with XML but it is not jQuery's design goal to support peculiars of XML dialects like SVG, VML, etc. or to give generic XML the same interfaces as an HTML DOM.
Fortunately you have .attr()
and can set whatever attributes you'd like on the XML.
Changed December 21, 2012 03:25PM UTC by comment:6
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → patchwelcome |
status: | reopened → closed |
If someone would like to make a patch to use .getAttribute("class")
instead of .class
it should include a jsperf. Be mindful of the size as well, it is probably better to use .getAttribute()
everywhere rather than branch the code.
Changed December 28, 2012 04:59PM UTC by comment:7
It's worth pointing out that add/removeClass has never worked as XML and it's been ok.
Do you have an example of a bug related to that? Please provide an example at jsfiddle.net or jsbin.com so we can see what's up.