Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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 referenced this pull request from a commit in buddydvd/zepto
@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
This page is out of date. Refresh to see the latest.
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.