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

fix(tooltip): do not toggle when isOpen is not boolean #4400

Closed
wants to merge 1 commit into from

Conversation

wesleycho
Copy link
Contributor

  • Coerce isOpen to boolean to do a proper comparison for firing
    toggleTooltipBind

Here is the fix in action.

This fixes #4335.

- Coerce `isOpen` to boolean to do a proper comparison for firing
  `toggleTooltipBind`
@wesleycho wesleycho force-pushed the fix/tooltip-undefined branch from dd9de6f to 7a6c8e7 Compare September 11, 2015 01:51
@Foxandxss
Copy link
Contributor

Not sure if that is readable or not. One important thing. If you deactivate a JSHINT rule (with -WXXX) you have to put it after the code that is breaking the rule (+WXXX).

I would also add a test.

@wesleycho
Copy link
Contributor Author

Can you explain about the readable and jshint parts?

There is no other good way to write this, due to val possibly not being a boolean, and a strict comparison is being done to a boolean. I could change it to a weak equality check, but that is pretty onerous and it becomes unobvious why we would want a weak check.

For the jshint change, can you explain with an example block of what you mean?

@Foxandxss
Copy link
Contributor

Of course.

Readable for me is because you need more than a couple of seconds to realize what is going on on that line. If you say there is no better way, I am fine with it. The biggest issue for me is having to disable jshint rules for me, that is like a big sign of "Are you sure?".

I am not up to date with the issue, but can't you do something like:

val = !!val;
if (val !== ttScope.isOpen) { .. }

At least to avoid jshint.

Now, about the jshint thing. You know that jshint has lot of rules and they will make you fail the checking.

To avoid that, you can disable a jshint rule with that you did, but that will disable it for the rest of the file. You can put the rule up again. So the idea is:

 /* jshint -W123 */
// Code that breaks rule 123
 /* jshint +W123 */
// Rule 123 is activated again

You can see that in action here: https://github.com/angular/angular.js/blob/master/src/ng/parse.js#L805-L821

Where angular disables the "new Function" protection because they needed it.

@wesleycho
Copy link
Contributor Author

I could make the change, but IMO it doesn't make it any easier to read - my opinion is that JSHint is wrong here, but it doesn't sound like they're going to change their stance on this from what I could tell.

I'll make the changes necessary and write a test around this sometime this weekend.

@Foxandxss
Copy link
Contributor

Don't bother wes. Leave it as is (fixing jshint rule) and add that test please.

@jikkujj
Copy link

jikkujj commented Sep 21, 2015

How do i help get this change as part of a build? Am new to all this

@wesleycho wesleycho deleted the fix/tooltip-undefined branch November 7, 2015 22:46
jasonaden pushed a commit to deskfed/bootstrap that referenced this pull request Jan 8, 2016
This is a rollup commit intended to address several
issues around the positioning and parsing of
attributes.

- Fixes issue introduced under PR angular-ui#4311 where setting
  height and width in tooltip position function
  messed up arrow placement.
- Fixes issue introduced under PR angular-ui#4363 where setting
  visibility to hidden in tooltip position function
  caused elements in popover to lose focus.
- Fixes issue angular-ui#1780 where tooltip would render if
  content was just whitespace.
- Fixes issue angular-ui#3347 where tooltip isolate scope was
  being accessed after it was set to null.  Observers
  will now be created/destroyed as tooltip opens/closes
  which will also offer a performance improvement.
- Fixes issue angular-ui#3557 by implementing evalAsync to set
  tooltip scope isOpen property.
- Fixes issue angular-ui#4335 where if model isOpen property is
  undefined, tooltip would call show/hide toggle function.
- Closes PR angular-ui#4429 where how the templated content
  was being evaluated could cause an infinite digest loop.

Closes angular-ui#4400
Closes angular-ui#4418
Closes angular-ui#4429
Closes angular-ui#4431
Closes angular-ui#4455

Fixes angular-ui#1780
Fixes angular-ui#3347
Fixes angular-ui#3557
Fixes angular-ui#4321
Fixes angular-ui#4335
jasonaden pushed a commit to deskfed/bootstrap that referenced this pull request Jan 8, 2016
This is a rollup commit intended to address several
issues around the positioning and parsing of
attributes.

- Fixes issue introduced under PR angular-ui#4311 where setting
  height and width in tooltip position function
  messed up arrow placement.
- Fixes issue introduced under PR angular-ui#4363 where setting
  visibility to hidden in tooltip position function
  caused elements in popover to lose focus.
- Fixes issue angular-ui#1780 where tooltip would render if
  content was just whitespace.
- Fixes issue angular-ui#3347 where tooltip isolate scope was
  being accessed after it was set to null.  Observers
  will now be created/destroyed as tooltip opens/closes
  which will also offer a performance improvement.
- Fixes issue angular-ui#3557 by implementing evalAsync to set
  tooltip scope isOpen property.
- Fixes issue angular-ui#4335 where if model isOpen property is
  undefined, tooltip would call show/hide toggle function.
- Closes PR angular-ui#4429 where how the templated content
  was being evaluated could cause an infinite digest loop.

Closes angular-ui#4400
Closes angular-ui#4418
Closes angular-ui#4429
Closes angular-ui#4431
Closes angular-ui#4455

Fixes angular-ui#1780
Fixes angular-ui#3347
Fixes angular-ui#3557
Fixes angular-ui#4321
Fixes angular-ui#4335
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.

Using is-open with popovers will display the popover by default
3 participants