Skip to content

Loading…

hasClass() compatible with SVG DOM where SVGAnimatedString is used #468

Closed
wants to merge 1 commit into from

2 participants

@DavidDurman

Hi,

I'm using Zepto with SVG and it works great so far. Not sure what's the philosophy of Zepto with regards to SVG DOM but I encountered a little issue with hasClass() function which is not compatible with SVG dom.

class in SVG DOM is a SVGAnimatedString with two properties baseVal and animVal where both are of DOMString type. I'm using the baseVal value in my fix to get the proper DOMString.

If you like it, more fixes will come in all places where className is used.

@mislav
Collaborator

I like it. I would like fixes for all className methods, but with tests of course.

@mislav mislav closed this in 122b014
@mislav
Collaborator

All code that touches className now taught SVG. Please review. Thanks!

@lopper lopper added a commit to buddydvd/zepto that referenced this pull request
@mislav mislav support manipulating classnames on SVG elements
Fixes #468
d62cf1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 5, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/zepto.js
View
2 src/zepto.js
@@ -343,7 +343,7 @@ var Zepto = (function() {
},
hasClass: function(name){
if (this.length < 1) return false;
- else return classRE(name).test(this[0].className);
+ else return classRE(name).test(this[0].className.baseVal === undefined ? this[0].className : this[0].className.baseVal);
},
addClass: function(name){
return this.each(function(idx) {
Something went wrong with that request. Please try again.