mirror of
https://github.com/twbs/bootstrap.git
synced 2025-09-26 13:29:06 +02:00
Allow Tooltips/Popovers to work in shadow DOM
This commit is contained in:
@@ -124,4 +124,42 @@ $(function () {
|
||||
assert.expect(1)
|
||||
assert.ok(Util.supportsTransitionEnd())
|
||||
})
|
||||
|
||||
QUnit.test('Util.findShadowRoot should find the shadow DOM root', function (assert) {
|
||||
// Only for newer browsers
|
||||
if (!document.documentElement.attachShadow) {
|
||||
assert.expect(0)
|
||||
return
|
||||
}
|
||||
|
||||
assert.expect(2)
|
||||
var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture'))
|
||||
var shadowRoot = $div[0].attachShadow({
|
||||
mode: 'open'
|
||||
})
|
||||
console.warn($div[0].attachShadow, shadowRoot)
|
||||
|
||||
assert.equal(shadowRoot, Util.findShadowRoot(shadowRoot))
|
||||
shadowRoot.innerHTML = '<button>Shadow Button</button>'
|
||||
assert.equal(shadowRoot, Util.findShadowRoot(shadowRoot.firstChild))
|
||||
})
|
||||
|
||||
QUnit.test('Util.findShadowRoot should return null when attachShadow is not available', function (assert) {
|
||||
assert.expect(1)
|
||||
|
||||
var $div = $('<div id="test"></div>').appendTo($('#qunit-fixture'))
|
||||
if (!document.documentElement.attachShadow) {
|
||||
assert.equal(null, Util.findShadowRoot($div[0]))
|
||||
} else {
|
||||
var sandbox = sinon.createSandbox()
|
||||
|
||||
sandbox.replace(document.documentElement, 'attachShadow', function () {
|
||||
// to avoid empty function
|
||||
return $div
|
||||
})
|
||||
|
||||
assert.equal(null, Util.findShadowRoot($div[0]))
|
||||
sandbox.restore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user