Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b96e978

Browse files
mheveryIgorMinar
authored andcommitted
fix(jqlite): removeClass would clobber class names
1 parent bda2bba commit b96e978

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/jqLite.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ function JQLiteData(element, key, value) {
208208
function JQLiteHasClass(element, selector, _) {
209209
// the argument '_' is important, since it makes the function have 3 arguments, which
210210
// is needed for delegate function to realize the this is a getter.
211-
var className = " " + selector + " ";
212-
return ((" " + element.className + " ").replace(/[\n\t]/g, " ").indexOf( className ) > -1);
211+
return ((" " + element.className + " ").replace(/[\n\t]/g, " ").
212+
indexOf( " " + selector + " " ) > -1);
213213
}
214214

215215
function JQLiteRemoveClass(element, selector) {

test/jqLiteSpec.js

+6
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,16 @@ describe('jqLite', function(){
318318
describe('removeClass', function(){
319319
it('should allow removal of class', function(){
320320
var selector = jqLite([a, b]);
321+
selector.addClass('a');
322+
selector.addClass('b');
323+
selector.addClass('c');
321324
expect(selector.addClass('abc')).toEqual(selector);
322325
expect(selector.removeClass('abc')).toEqual(selector);
323326
expect(jqLite(a).hasClass('abc')).toEqual(false);
324327
expect(jqLite(b).hasClass('abc')).toEqual(false);
328+
expect(jqLite(a).hasClass('a')).toEqual(true);
329+
expect(jqLite(a).hasClass('b')).toEqual(true);
330+
expect(jqLite(a).hasClass('c')).toEqual(true);
325331
});
326332

327333

0 commit comments

Comments
 (0)