Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(components): fix issue with removeClass removing previous classes
Browse files Browse the repository at this point in the history
In certain parts of the project, a "removeClass(className)" is used to remove the class from the element. While this works fine in latest versions of jQuery, in jQuery < 1.9 this results in the element classes being removed when className is undefined, thus breaking the whole layout.

Closes #5538.
  • Loading branch information
mallowigi authored and ThomasBurleson committed Nov 5, 2015
1 parent e5fa785 commit bd65bf7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/checkbox/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function MdCheckboxDirective(inputDirective, $mdAria, $mdConstant, $mdTheming, $
if(ngModelCtrl.$viewValue) {
element.addClass(CHECKED_CSS);
} else {
element.removeClass(CHECKED_CSS);
if (CHECKED_CSS) element.removeClass(CHECKED_CSS);
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/progressCircular/progress-circular.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ function MdProgressCircularDirective($mdTheming, $mdUtil, $log) {
case MODE_DETERMINATE:
case MODE_INDETERMINATE:
spinnerWrapper.removeClass('ng-hide');
spinnerWrapper.removeClass( lastMode );
if (lastMode) spinnerWrapper.removeClass(lastMode);
spinnerWrapper.addClass( lastMode = "md-mode-" + mode );
break;
default:
spinnerWrapper.removeClass( lastMode );
if (lastMode) spinnerWrapper.removeClass( lastMode );
spinnerWrapper.addClass('ng-hide');
lastMode = undefined;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/components/progressLinear/progress-linear.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function MdProgressLinearDirective($mdTheming, $mdUtil, $log) {
container.addClass( lastMode = "md-mode-" + mode );
break;
default:
container.removeClass( lastMode );
if (lastMode) container.removeClass( lastMode );
container.addClass('ng-hide');
lastMode = undefined;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/components/radioButton/radio-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@ function mdRadioButtonDirective($mdAria, $mdUtil, $mdTheming) {

} else {
markParentAsChecked(false);
element.removeClass(CHECKED_CSS);
if (CHECKED_CSS) element.removeClass(CHECKED_CSS);
}

/**
* If the radioButton is inside a div, then add class so highlighting will work...
*/
function markParentAsChecked(addClass ) {
if ( element.parent()[0].nodeName != "MD-RADIO-GROUP") {
element.parent()[ !!addClass ? 'addClass' : 'removeClass'](CHECKED_CSS);
if (CHECKED_CSS) element.parent()[ !!addClass ? 'addClass' : 'removeClass'](CHECKED_CSS);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ function MdToastProvider($$interimElementProvider) {

function onRemove(scope, element, options) {
element.off(SWIPE_EVENTS, options.onSwipe);
options.parent.removeClass(options.openClass);
if (options.openClass) options.parent.removeClass(options.openClass);

return (options.$destroy == true) ? element.remove() : $animate.leave(element);
}
Expand Down
2 changes: 1 addition & 1 deletion test/angular-material-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

// Prepare auto-restore
enableAnimations = function() {
body.removeClass(DISABLE_ANIMATIONS);
if (DISABLE_ANIMATIONS) body.removeClass(DISABLE_ANIMATIONS);
styleSheet.remove();
};
};
Expand Down

0 comments on commit bd65bf7

Please sign in to comment.