Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#47 - be careful to not assume that the tooltip defined is, in fact, … #48

Merged
merged 1 commit into from May 14, 2016

Conversation

coladarci
Copy link
Contributor

…the type of tooltip we are expecting

@sir-dunxalot
Copy link
Owner

I'm just seeing this sorry.

Would a slightly more robust approach be to check if the constructor of tooltip is this library's Tooltip class?

@coladarci
Copy link
Contributor Author

I tend to avoid that in JS, though if my concern is outdated, let me know. In any other language, that's exactly what you'd do... See this question for more context http://stackoverflow.com/questions/7039260/can-i-use-constructor-name-to-detect-types-in-javascript

@sir-dunxalot
Copy link
Owner

I believe instanceof is pretty safe these days. I'd probably advocate for that approach instead of checking for the detach method.

@coladarci
Copy link
Contributor Author

Not sure what to do about the failing tests; the fail for me locally as well but can't imagine my change is responsible for a sass fail! Any thoughts?

@@ -62,7 +63,7 @@ export default Ember.Mixin.create({
destroyTooltip: on('willDestroyElement', function() {
const tooltip = this.get('tooltip');

if (tooltip && Ember.typeOf(tooltip) === 'object') {
if (tooltip && tooltip instanceof Tooltip) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sir-dunxalot - take a look - I've updated this pull to do the instanceof check you suggested. It's worth noting that it looks like another attempt at fixing this bug was merged here 432a943#diff-6d875f075dad177398e49011cc51f439R65 but that is simply not a good enough check; the collision in my case is w/ another object. (For others who might be reading this, https://github.com/Glavin001/ember-c3 uses a property tooltips - (a hash, therefore also an object) for it's graphs, so just by adding this tooltip library, any time you navigate away from a graph, your app crashes since this library is added to every component and hooks into the willDestroyElement).

I've tested this w/ my app and it works for me, would love very much to get a release of this!

Copy link
Owner

Choose a reason for hiding this comment

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

Great, thanks for the update. I'll get on this ASAP so we can make another release - likely sometime this week.

@sir-dunxalot sir-dunxalot merged commit 51f8f7d into sir-dunxalot:master May 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants