mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-08 14:54:44 +00:00
fix(jqlite): removeClass would clobber class names
This commit is contained in:
parent
bda2bba2be
commit
b96e978178
2 changed files with 8 additions and 2 deletions
|
|
@ -208,8 +208,8 @@ function JQLiteData(element, key, value) {
|
||||||
function JQLiteHasClass(element, selector, _) {
|
function JQLiteHasClass(element, selector, _) {
|
||||||
// the argument '_' is important, since it makes the function have 3 arguments, which
|
// the argument '_' is important, since it makes the function have 3 arguments, which
|
||||||
// is needed for delegate function to realize the this is a getter.
|
// is needed for delegate function to realize the this is a getter.
|
||||||
var className = " " + selector + " ";
|
return ((" " + element.className + " ").replace(/[\n\t]/g, " ").
|
||||||
return ((" " + element.className + " ").replace(/[\n\t]/g, " ").indexOf( className ) > -1);
|
indexOf( " " + selector + " " ) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function JQLiteRemoveClass(element, selector) {
|
function JQLiteRemoveClass(element, selector) {
|
||||||
|
|
|
||||||
|
|
@ -318,10 +318,16 @@ describe('jqLite', function(){
|
||||||
describe('removeClass', function(){
|
describe('removeClass', function(){
|
||||||
it('should allow removal of class', function(){
|
it('should allow removal of class', function(){
|
||||||
var selector = jqLite([a, b]);
|
var selector = jqLite([a, b]);
|
||||||
|
selector.addClass('a');
|
||||||
|
selector.addClass('b');
|
||||||
|
selector.addClass('c');
|
||||||
expect(selector.addClass('abc')).toEqual(selector);
|
expect(selector.addClass('abc')).toEqual(selector);
|
||||||
expect(selector.removeClass('abc')).toEqual(selector);
|
expect(selector.removeClass('abc')).toEqual(selector);
|
||||||
expect(jqLite(a).hasClass('abc')).toEqual(false);
|
expect(jqLite(a).hasClass('abc')).toEqual(false);
|
||||||
expect(jqLite(b).hasClass('abc')).toEqual(false);
|
expect(jqLite(b).hasClass('abc')).toEqual(false);
|
||||||
|
expect(jqLite(a).hasClass('a')).toEqual(true);
|
||||||
|
expect(jqLite(a).hasClass('b')).toEqual(true);
|
||||||
|
expect(jqLite(a).hasClass('c')).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue