1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-29 16:19:53 +02:00

feat(RTL): implement RTL

Using RTLCSS directives, renaming things to use logical names and following best practices.
This commit is contained in:
Gaël Poupard
2020-06-26 17:06:20 +03:00
committed by XhmikosR
parent 71ecc3323f
commit 9488978fb5
37 changed files with 301 additions and 200 deletions

View File

@@ -227,7 +227,7 @@ describe('Dropdown', () => {
fixtureEl.innerHTML = [
'<div class="dropdown">',
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>',
' <div class="dropdown-menu dropdown-menu-right">',
' <div class="dropdown-menu dropdown-menu-end">',
' <a class="dropdown-item" href="#">Secondary link</a>',
' </div>',
'</div>'
@@ -273,7 +273,7 @@ describe('Dropdown', () => {
fixtureEl.innerHTML = [
'<div class="dropup">',
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>',
' <div class="dropdown-menu dropdown-menu-right">',
' <div class="dropdown-menu dropdown-menu-end">',
' <a class="dropdown-item" href="#">Secondary link</a>',
' </div>',
'</div>'
@@ -292,9 +292,9 @@ describe('Dropdown', () => {
dropdown.toggle()
})
it('should toggle a dropright', done => {
it('should toggle a dropend', done => {
fixtureEl.innerHTML = [
'<div class="dropright">',
'<div class="dropend">',
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>',
' <div class="dropdown-menu">',
' <a class="dropdown-item" href="#">Secondary link</a>',
@@ -303,10 +303,10 @@ describe('Dropdown', () => {
].join('')
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
const droprightEl = fixtureEl.querySelector('.dropright')
const dropendEl = fixtureEl.querySelector('.dropend')
const dropdown = new Dropdown(btnDropdown)
droprightEl.addEventListener('shown.bs.dropdown', () => {
dropendEl.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()
@@ -315,9 +315,9 @@ describe('Dropdown', () => {
dropdown.toggle()
})
it('should toggle a dropleft', done => {
it('should toggle a dropstart', done => {
fixtureEl.innerHTML = [
'<div class="dropleft">',
'<div class="dropstart">',
' <button class="btn dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button>',
' <div class="dropdown-menu">',
' <a class="dropdown-item" href="#">Secondary link</a>',
@@ -326,10 +326,10 @@ describe('Dropdown', () => {
].join('')
const btnDropdown = fixtureEl.querySelector('[data-bs-toggle="dropdown"]')
const dropleftEl = fixtureEl.querySelector('.dropleft')
const dropstartEl = fixtureEl.querySelector('.dropstart')
const dropdown = new Dropdown(btnDropdown)
dropleftEl.addEventListener('shown.bs.dropdown', () => {
dropstartEl.addEventListener('shown.bs.dropdown', () => {
expect(btnDropdown.classList.contains('show')).toEqual(true)
expect(btnDropdown.getAttribute('aria-expanded')).toEqual('true')
done()

View File

@@ -46,7 +46,7 @@ describe('Toast', () => {
it('should close toast when close element with data-bs-dismiss attribute is set', done => {
fixtureEl.innerHTML = [
'<div class="toast" data-bs-delay="1" data-bs-autohide="false" data-bs-animation="false">',
' <button type="button" class="ml-2 mb-1 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>',
' <button type="button" class="ms-2 mb-1 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>',
'</div>'
].join('')
@@ -78,7 +78,7 @@ describe('Toast', () => {
fixtureEl.innerHTML = [
'<div class="toast" data-bs-autohide="false" data-bs-animation="false">',
' <button type="button" class="ml-2 mb-1 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>',
' <button type="button" class="ms-2 mb-1 btn-close" data-bs-dismiss="toast" aria-label="Close"></button>',
'</div>'
].join('')

View File

@@ -886,6 +886,40 @@ describe('Tooltip', () => {
})
})
describe('updateAttachment', () => {
it('should use end class name when right placement specified', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
placement: 'right'
})
tooltipEl.addEventListener('inserted.bs.tooltip', () => {
expect(tooltip.getTipElement().classList.contains('bs-tooltip-end')).toEqual(true)
done()
})
tooltip.show()
})
it('should use start class name when left placement specified', done => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'
const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
placement: 'left'
})
tooltipEl.addEventListener('inserted.bs.tooltip', () => {
expect(tooltip.getTipElement().classList.contains('bs-tooltip-start')).toEqual(true)
done()
})
tooltip.show()
})
})
describe('setElementContent', () => {
it('should do nothing if the element is null', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip">'