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

fix(all): fix issue with removeClass removing previous classes #5538

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do this if( ...) when CHECKED_CSS is defined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, this is a constant. I just did a full search for removeClass with variables, I didn't pay attention to the details.

}
}
};
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this not work spinnerWrapper.removeClass(lastMode || "")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it could work too. Why? Is there a problem with the null check?

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 @@ -260,7 +260,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