From 64fd2c421ed582c16812d164a8a6f031b8e66287 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Wed, 9 Oct 2013 13:51:59 -0700 Subject: fix(jqLite): ignore class methods on comment elements Since c785267e jqLite uses setAttribute (rather than className property) in order to change classes. Some elements (eg. Comment) do not have this method which blows up. jQuery silently ignores these method calls (because it uses className), so to get the same behavior as jQuery, we check for setAttribute method first. --- test/jqLiteSpec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/jqLiteSpec.js') diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index de9c74da..24920273 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -493,6 +493,16 @@ describe('jqLite', function() { }); + it('should ignore comment elements', function() { + var comment = jqLite(document.createComment('something')); + + comment.addClass('whatever'); + comment.hasClass('whatever'); + comment.toggleClass('whatever'); + comment.removeClass('whatever'); + }); + + describe('hasClass', function() { it('should check class', function() { var selector = jqLite([a, b]); -- cgit v1.2.3