mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-15 10:05:40 +02:00
Allow Tooltips/Popovers to work in shadow DOM
This commit is contained in:
@@ -62,7 +62,12 @@
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
<div id="target" title="Test tooltip on transformed element"></div>
|
||||
<div class="row">
|
||||
<div class="col-sm-3">
|
||||
<div id="target" title="Test tooltip on transformed element"></div>
|
||||
</div>
|
||||
<div id="shadow" class="pt-5"></div>
|
||||
</div>
|
||||
<div id="customContainer"></div>
|
||||
</div>
|
||||
|
||||
@@ -72,6 +77,21 @@
|
||||
<script src="../../dist/tooltip.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
if (typeof document.body.attachShadow === 'function') {
|
||||
var shadowRoot = $('#shadow')[0].attachShadow({ mode: 'open' })
|
||||
shadowRoot.innerHTML =
|
||||
'<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top in a shadow dom">' +
|
||||
' Tooltip on top in a shadow dom' +
|
||||
'</button>' +
|
||||
'<button id="secondTooltip" type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top in a shadow dom with container option">' +
|
||||
' Tooltip on top in a shadow dom' +
|
||||
'</button>'
|
||||
|
||||
$(shadowRoot.firstChild).tooltip()
|
||||
$(shadowRoot.getElementById('secondTooltip')).tooltip({
|
||||
container: shadowRoot
|
||||
})
|
||||
}
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
$('#tooltipElement').tooltip({
|
||||
container: $('#customContainer')[0]
|
||||
|
Reference in New Issue
Block a user