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

Update tooltip.js #19541

Merged
merged 2 commits into from
Dec 22, 2016
Merged
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 js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Tooltip = (($) => {
* Check for Tether dependency
* Tether - http://github.hubspot.com/tether/
*/
if (window.Tether === undefined) {
if (typeof Tether === 'undefined') {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just : if (Tether === undefined) ?
Your JSPerf prove it's faster than using typeof

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Johann-S That will throw an exception if Tether isn't defined...

if (someUndefinedValue === undefined) console.log('success')
// Uncaught ReferenceError someUndefinedValue is not defined

//this would work, but sloppier than the typeof
try {
  if (Tether){}
} catch(err) {
  throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/');
}

throw new Error('Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)')
}

Expand Down