Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bootstrap
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
bootstrap
Commits
fc372952
Commit
fc372952
authored
Apr 21, 2015
by
Chris Rebert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Throw error when tooltip/popover template has multiple top-level elements
Closes #16219.
parent
8949bcec
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
1 deletion
+28
-1
js/tests/unit/popover.js
js/tests/unit/popover.js
+11
-0
js/tests/unit/tooltip.js
js/tests/unit/tooltip.js
+10
-0
js/tooltip.js
js/tooltip.js
+7
-1
No files found.
js/tests/unit/popover.js
View file @
fc372952
...
@@ -259,6 +259,16 @@ $(function () {
...
@@ -259,6 +259,16 @@ $(function () {
assert
.
strictEqual
(
$popover
.
data
(
'
bs.popover
'
),
undefined
,
'
should not initialize the popover
'
)
assert
.
strictEqual
(
$popover
.
data
(
'
bs.popover
'
),
undefined
,
'
should not initialize the popover
'
)
})
})
QUnit
.
test
(
'
should throw an error when template contains multiple top-level elements
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
assert
.
throws
(
function
()
{
$
(
'
<span data-toggle="popover" data-title="some title" data-content="some content">some text</span>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapPopover
({
template
:
'
<div>Foo</div><div>Bar</div>
'
})
.
bootstrapPopover
(
'
show
'
)
},
new
Error
(
'
popover `template` option must consist of exactly 1 top-level element!
'
))
})
QUnit
.
test
(
'
should fire inserted event
'
,
function
(
assert
)
{
QUnit
.
test
(
'
should fire inserted event
'
,
function
(
assert
)
{
assert
.
expect
(
2
)
assert
.
expect
(
2
)
var
done
=
assert
.
async
()
var
done
=
assert
.
async
()
...
@@ -276,4 +286,5 @@ $(function () {
...
@@ -276,4 +286,5 @@ $(function () {
})
})
.
bootstrapPopover
(
'
show
'
)
.
bootstrapPopover
(
'
show
'
)
})
})
})
})
js/tests/unit/tooltip.js
View file @
fc372952
...
@@ -1225,4 +1225,14 @@ $(function () {
...
@@ -1225,4 +1225,14 @@ $(function () {
assert
.
strictEqual
(
$tooltip
.
data
(
'
bs.tooltip
'
),
undefined
,
'
should not initialize the tooltip
'
)
assert
.
strictEqual
(
$tooltip
.
data
(
'
bs.tooltip
'
),
undefined
,
'
should not initialize the tooltip
'
)
})
})
QUnit
.
test
(
'
should throw an error when template contains multiple top-level elements
'
,
function
(
assert
)
{
assert
.
expect
(
1
)
assert
.
throws
(
function
()
{
$
(
'
<a href="#" data-toggle="tooltip" title="Another tooltip"></a>
'
)
.
appendTo
(
'
#qunit-fixture
'
)
.
bootstrapTooltip
({
template
:
'
<div>Foo</div><div>Bar</div>
'
})
.
bootstrapTooltip
(
'
show
'
)
},
new
Error
(
'
tooltip `template` option must consist of exactly 1 top-level element!
'
))
})
})
})
js/tooltip.js
View file @
fc372952
...
@@ -404,7 +404,13 @@
...
@@ -404,7 +404,13 @@
}
}
Tooltip
.
prototype
.
tip
=
function
()
{
Tooltip
.
prototype
.
tip
=
function
()
{
return
(
this
.
$tip
=
this
.
$tip
||
$
(
this
.
options
.
template
))
if
(
!
this
.
$tip
)
{
this
.
$tip
=
$
(
this
.
options
.
template
)
if
(
this
.
$tip
.
length
!=
1
)
{
throw
new
Error
(
this
.
type
+
'
`template` option must consist of exactly 1 top-level element!
'
)
}
}
return
this
.
$tip
}
}
Tooltip
.
prototype
.
arrow
=
function
()
{
Tooltip
.
prototype
.
arrow
=
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment