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

Remove DOMContentLoaded. #28337

Merged
merged 1 commit into from
Feb 24, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions js/tests/visual/carousel.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,18 @@ <h1>Carousel <small>Bootstrap Visual Test</small></h1>
<script src="../../dist/util.js"></script>
<script src="../../dist/carousel.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
var t0, t1;
var carousel = document.getElementById('carousel-example-generic')
var t0
var t1
var carousel = document.getElementById('carousel-example-generic')

// Test to show that the carousel doesn't slide when the current tab isn't visible
// Test to show that transition-duration can be changed with css
carousel.addEventListener('slid.bs.carousel', function (event) {
t1 = performance.now()
console.log('transition-duration took ' + (t1 - t0) + 'ms, slid at ', event.timeStamp)
})
carousel.addEventListener('slide.bs.carousel', function () {
t0 = performance.now()
})
// Test to show that the carousel doesn't slide when the current tab isn't visible
// Test to show that transition-duration can be changed with css
carousel.addEventListener('slid.bs.carousel', function (event) {
t1 = performance.now()
console.log('transition-duration took ' + (t1 - t0) + 'ms, slid at ', event.timeStamp)
})
carousel.addEventListener('slide.bs.carousel', function () {
t0 = performance.now()
})
</script>
</body>
Expand Down
125 changes: 61 additions & 64 deletions js/tests/visual/modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -217,86 +217,83 @@ <h4 class="modal-title" id="slowModalLabel">Lorem slowly</h4>
<script src="../../dist/tooltip.js"></script>
<script src="../../dist/popover.js"></script>
<script>
var ffBugTestResult = document.getElementById('ff-bug-test-result')
var firefoxTestDone = false
document.addEventListener('DOMContentLoaded', function () {
var ffBugTestResult = document.getElementById('ff-bug-test-result')

function reportFirefoxTestResult(result) {
if (!firefoxTestDone) {
ffBugTestResult.classList
.add(result ? 'text-success' : 'text-danger')

ffBugTestResult.innerHTML = result ? 'PASS' : 'FAIL'
}
function reportFirefoxTestResult(result) {
if (!firefoxTestDone) {
ffBugTestResult.classList.add(result ? 'text-success' : 'text-danger')
ffBugTestResult.innerHTML = result ? 'PASS' : 'FAIL'
}
}

[].slice.call(document.querySelectorAll('[data-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})

var tooltipList = [].slice.call(document.querySelectorAll('[data-toggle="tooltip"]'))
tooltipList.forEach(function (tooltip) {
new Tooltip(tooltip)
})

var tallToggle = document.getElementById('tall-toggle')
var tall = document.getElementById('tall')
tallToggle.addEventListener('click', function () {
if (tall.style.display === 'none') {
tall.style.display = 'block'
} else {
tall.style.display = 'none'
}
[].slice.call(document.querySelectorAll('[data-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})

var ffBugInput = document.getElementById('ff-bug-input')
var firefoxModal = document.getElementById('firefoxModal')
function handlerClickFfBugInput() {
firefoxModal.addEventListener('focus', reportFirefoxTestResult.bind(false))
ffBugInput.addEventListener('focus', reportFirefoxTestResult.bind(true))
ffBugInput.removeEventListener('focus', handlerClickFfBugInput)
var tooltipList = [].slice.call(document.querySelectorAll('[data-toggle="tooltip"]'))
tooltipList.forEach(function (tooltip) {
new Tooltip(tooltip)
})

var tallToggle = document.getElementById('tall-toggle')
var tall = document.getElementById('tall')
tallToggle.addEventListener('click', function () {
if (tall.style.display === 'none') {
tall.style.display = 'block'
} else {
tall.style.display = 'none'
}
ffBugInput.addEventListener('focus', handlerClickFfBugInput)
})

var btnPreventModal = document.getElementById('btnPreventModal')
var modalFf = new Modal(firefoxModal)
var ffBugInput = document.getElementById('ff-bug-input')
var firefoxModal = document.getElementById('firefoxModal')
function handlerClickFfBugInput() {
firefoxModal.addEventListener('focus', reportFirefoxTestResult.bind(false))
ffBugInput.addEventListener('focus', reportFirefoxTestResult.bind(true))
ffBugInput.removeEventListener('focus', handlerClickFfBugInput)
}
ffBugInput.addEventListener('focus', handlerClickFfBugInput)

btnPreventModal.addEventListener('click', function () {
function shownFirefoxModal() {
modalFf.hide()
firefoxModal.removeEventListener('shown.bs.modal', hideFirefoxModal)
}
var btnPreventModal = document.getElementById('btnPreventModal')
var modalFf = new Modal(firefoxModal)

function hideFirefoxModal(event) {
event.preventDefault()
firefoxModal.removeEventListener('hide.bs.modal', hideFirefoxModal)
btnPreventModal.addEventListener('click', function () {
function shownFirefoxModal() {
modalFf.hide()
firefoxModal.removeEventListener('shown.bs.modal', hideFirefoxModal)
}

function hideFirefoxModal(event) {
event.preventDefault()
firefoxModal.removeEventListener('hide.bs.modal', hideFirefoxModal)

if (modalFf._isTransitioning) {
console.error('Modal plugin should not set _isTransitioning when hide event is prevented')
} else {
console.log('Test passed')
modalFf.hide() // work as expected
}
if (modalFf._isTransitioning) {
console.error('Modal plugin should not set _isTransitioning when hide event is prevented')
} else {
console.log('Test passed')
modalFf.hide() // work as expected
}
}

firefoxModal.addEventListener('shown.bs.modal', shownFirefoxModal)
firefoxModal.addEventListener('hide.bs.modal', hideFirefoxModal)
modalFf.show()
})
firefoxModal.addEventListener('shown.bs.modal', shownFirefoxModal)
firefoxModal.addEventListener('hide.bs.modal', hideFirefoxModal)
modalFf.show()
})

// Test transition duration
var t0, t1;
var slowModal = document.getElementById('slowModal')
// Test transition duration
var t0
var t1
var slowModal = document.getElementById('slowModal')

slowModal.addEventListener('shown.bs.modal', function () {
t1 = performance.now()
console.log('transition-duration took ' + (t1 - t0) + 'ms.')
})
slowModal.addEventListener('shown.bs.modal', function () {
t1 = performance.now()
console.log('transition-duration took ' + (t1 - t0) + 'ms.')
})

slowModal.addEventListener('show.bs.modal', function () {
t0 = performance.now()
})
slowModal.addEventListener('show.bs.modal', function () {
t0 = performance.now()
})
</script>
</body>
Expand Down
10 changes: 4 additions & 6 deletions js/tests/visual/popover.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ <h1>Popover <small>Bootstrap Visual Test</small></h1>
<script src="../../dist/tooltip.js"></script>
<script src="../../dist/popover.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
[].slice.call(document.querySelectorAll('[data-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})
})
[].slice.call(document.querySelectorAll('[data-toggle="popover"]'))
.forEach(function (popover) {
new Popover(popover)
})
</script>
</body>
</html>
56 changes: 27 additions & 29 deletions js/tests/visual/tooltip.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,40 +80,38 @@ <h1>Tooltip <small>Bootstrap Visual Test</small></h1>
<script src="../../dist/dom/selectorEngine.js"></script>
<script src="../../dist/tooltip.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
if (typeof document.body.attachShadow === 'function') {
var shadowRoot = document.getElementById('shadow').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>'
if (typeof document.body.attachShadow === 'function') {
var shadowRoot = document.getElementById('shadow').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>'

var firstChildTooltip = new Tooltip(shadowRoot.firstChild)
var secondChildTooltip = new Tooltip(shadowRoot.getElementById('secondTooltip'), {
container: shadowRoot
})
}

[].slice.call(document.querySelectorAll('[data-toggle="tooltip"]'))
.forEach(function (tooltip) {
new Tooltip(tooltip)
})

var tooltipElement = document.getElementById('tooltipElement')
var tooltipElementInstance = new Tooltip(tooltipElement, {
container: document.getElementById('customContainer')
var firstChildTooltip = new Tooltip(shadowRoot.firstChild)
var secondChildTooltip = new Tooltip(shadowRoot.getElementById('secondTooltip'), {
container: shadowRoot
})
}

var target = document.getElementById('target')
var targetTooltip = new Tooltip(target, {
placement : 'top',
trigger : 'manual'
[].slice.call(document.querySelectorAll('[data-toggle="tooltip"]'))
.forEach(function (tooltip) {
new Tooltip(tooltip)
})
targetTooltip.show()

var tooltipElement = document.getElementById('tooltipElement')
var tooltipElementInstance = new Tooltip(tooltipElement, {
container: document.getElementById('customContainer')
})

var target = document.getElementById('target')
var targetTooltip = new Tooltip(target, {
placement : 'top',
trigger : 'manual'
})
targetTooltip.show()
</script>
</body>
</html>
Loading