Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(accordion): add attr.openClass || 'panel-open' class when expanded #4198

Closed
wants to merge 1 commit into from

Conversation

davious
Copy link
Contributor

@davious davious commented Aug 13, 2015

uses toggleClass in isOpen watch
Fixes #4193

Review on Reviewable

scope.$watch('isOpen', function(value) {
element.toggleClass(scope.openClass, value);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is incorrect - if the element has a different class for some reason, this will cause a bug.

You will want

element[value ? 'addClass' : 'removeClass'](scope.openClass)

in this case to be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @wesleycho,
Thanks for reviewing the PR. I'd like to understand your concern better. Please provide an example so I can get on the same page.

Copy link
Contributor

Choose a reason for hiding this comment

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

Any DOM manipulation can be done to change the class of the element - in that case, relying on toggle to correctly toggle the class would be completely incorrect, since it makes a poor assumption that the actual class reflects the state of isOpen. The coupling of the model value and the DOM value is not strong enough to make this assumption in a library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wesleycho
how about
element.toggleClass(scope.openClass, !!value);
is that OK?

Copy link
Contributor

Choose a reason for hiding this comment

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

Still has the same flaw of using toggleClass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wesleycho
would you provide an example? If you are concerned with toggleClass mashing some other classes, I'm thinking toggleClass plays safe with them just like addClass and removeClass.

Copy link
Contributor

Choose a reason for hiding this comment

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

I apologize, I'm on not enough sleep it appears - this is completely fine due to the second parameter. Ignore my complaints here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wesleycho 😁 np. Thanks for staying up and accepting the PR

@wesleycho
Copy link
Contributor

This PR LGTM - will merge in sometime today.

@wesleycho wesleycho added this to the 0.13.4 (Performance) milestone Aug 13, 2015
@wesleycho wesleycho closed this in 575eb85 Aug 13, 2015
@davious davious deleted the accordion-group-class-alt branch August 16, 2015 20:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants