Permalink
Browse files

fix for ticket #86 in which empty class attributes were injected into…

… elements
  • Loading branch information...
1 parent 2490385 commit 10694fcf0fcc6cd579c38f573e7f60d587648ae6 @stenington stenington committed Oct 28, 2011
Showing with 18 additions and 2 deletions.
  1. +2 −2 src/mix-master.js
  2. +6 −0 src/utils.js
  3. +10 −0 test/unit/utils/utils.js
View
@@ -212,12 +212,12 @@
input: input,
element: newContent,
onDone: function() {
- newContent.removeClass('webxray-hidden');
+ newContent.reallyRemoveClass('webxray-hidden');
}
});
} else {
// TODO: Re-focus previously focused elements?
- $(focusedElement).removeClass('webxray-hidden');
+ $(focusedElement).reallyRemoveClass('webxray-hidden');
dialog.close();
}
}
View
@@ -180,6 +180,12 @@
this.resizeTo(target, function() {
$(this).fadeOut(function() { $(this).remove(); });
});
+ },
+ // Removes the class and, if the class attribute is now empty,
+ // removes the attribute as well (jQuery remove class does not)..
+ reallyRemoveClass: function reallyRemoveClass(classname) {
+ this.removeClass(classname).filter('[class=""]').removeAttr('class');
+ return this;
}
});
})(jQuery);
View
@@ -123,3 +123,13 @@ test("absolutifyURLs()", function() {
a = a.find('img');
equal(a[0].src, a.attr("src"), "URLs in child srcs are absolutified");
});
+
+test("reallyRemoveClass()", function() {
+ var $ = jQuery;
+
+ var a = $('<div class="foo"></div>');
+ var b = a.clone();
+
+ equal('<div class=""></div>', a.removeClass('foo').outerHtml());
+ equal('<div></div>', b.reallyRemoveClass('foo').outerHtml());
+});

0 comments on commit 10694fc

Please sign in to comment.