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

v4 : Making .tooltip('show') throw an error on elements with display:none #20940

Merged
merged 1 commit into from Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions js/src/tooltip.js
Expand Up @@ -239,6 +239,9 @@ const Tooltip = (($) => {
}

show() {
if ($(this.element).css('display') === 'none') {
throw new Error('Please use show on visible elements')
}
let showEvent = $.Event(this.constructor.Event.SHOW)

if (this.isWithContent() && this._isEnabled) {
Expand Down
12 changes: 12 additions & 0 deletions js/tests/unit/popover.js
Expand Up @@ -320,4 +320,16 @@ $(function () {
.bootstrapPopover('show')
})

QUnit.test('should throw an error when show is called on hidden elements', function (assert) {

Choose a reason for hiding this comment

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

'QUnit' is not defined no-undef
Unexpected function expression prefer-arrow-callback

Choose a reason for hiding this comment

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

'QUnit' is not defined no-undef
Unexpected function expression prefer-arrow-callback

Choose a reason for hiding this comment

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

'QUnit' is not defined no-undef
Unexpected function expression prefer-arrow-callback

assert.expect(1)
var done = assert.async()

Choose a reason for hiding this comment

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

Unexpected var, use let or const instead no-var

Choose a reason for hiding this comment

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

Unexpected var, use let or const instead no-var

Choose a reason for hiding this comment

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

Unexpected var, use let or const instead no-var


try {
$('<div data-toggle="popover" data-title="some title" data-content="@Johann-S" style="display: none"/>').bootstrapPopover('show')
}
catch (err) {

Choose a reason for hiding this comment

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

Closing curly brace does not appear on the same line as the subsequent block brace-style

Choose a reason for hiding this comment

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

Closing curly brace does not appear on the same line as the subsequent block brace-style

Choose a reason for hiding this comment

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

Closing curly brace does not appear on the same line as the subsequent block brace-style

assert.strictEqual(err.message, 'Please use show on visible elements')
done()
}
})
})
13 changes: 13 additions & 0 deletions js/tests/unit/tooltip.js
Expand Up @@ -185,6 +185,19 @@ $(function () {
.bootstrapTooltip('show')
})

QUnit.test('should throw an error when show is called on hidden elements', function (assert) {

Choose a reason for hiding this comment

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

'QUnit' is not defined no-undef
Unexpected function expression prefer-arrow-callback

Choose a reason for hiding this comment

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

'QUnit' is not defined no-undef
Unexpected function expression prefer-arrow-callback

Choose a reason for hiding this comment

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

'QUnit' is not defined no-undef
Unexpected function expression prefer-arrow-callback

assert.expect(1)
var done = assert.async()

Choose a reason for hiding this comment

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

Unexpected var, use let or const instead no-var

Choose a reason for hiding this comment

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

Unexpected var, use let or const instead no-var

Choose a reason for hiding this comment

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

Unexpected var, use let or const instead no-var


try {
$('<div title="tooltip title" style="display: none"/>').bootstrapTooltip('show')
}
catch (err) {

Choose a reason for hiding this comment

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

Closing curly brace does not appear on the same line as the subsequent block brace-style

Choose a reason for hiding this comment

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

Closing curly brace does not appear on the same line as the subsequent block brace-style

Choose a reason for hiding this comment

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

Closing curly brace does not appear on the same line as the subsequent block brace-style

assert.strictEqual(err.message, 'Please use show on visible elements')
done()
}
})

QUnit.test('should fire inserted event', function (assert) {
assert.expect(2)
var done = assert.async()
Expand Down