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

[OUDS] Bootstrap v5.3.4 #2595

Draft
wants to merge 1 commit into
base: ouds/main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@
"unicorn/prefer-module": "off",
"unicorn/prefer-query-selector": "off",
"unicorn/prefer-spread": "off",
"unicorn/prefer-string-raw": "off",
"unicorn/prefer-string-replace-all": "off",
"unicorn/prefer-structured-clone": "off",
"unicorn/prevent-abbreviations": "off"
},
"overrides": [
Expand Down
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ includes code changes) and under the terms of the

[Adhere to the Code Guide.](https://codeguide.co/#css)

- When feasible, default color palettes should comply with [WCAG color contrast guidelines](https://www.w3.org/TR/WCAG20/#visual-audio-contrast).
- When feasible, default color palettes should comply with [WCAG color contrast guidelines](https://www.w3.org/TR/WCAG/#distinguishable).
- Except in rare cases, don't remove default `:focus` styles (via e.g. `outline: none;`) without providing alternative styles. See [this A11Y Project post](https://www.a11yproject.com/posts/2013-01-25-never-remove-css-outlines/) for more details.

### JS
Expand Down
2 changes: 1 addition & 1 deletion hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ params:
current_ruby_version: "0.0.3"
docs_version: "0.0"
rfs_version: "v10.0.0"
bootstrap_current_version: "5.3.3"
bootstrap_current_version: "5.3.4"
bootstrap_docs_version: "5.3"
bootstrap_github_org: "https://github.com/twbs"
repo: "https://github.com/Orange-OpenSource/Orange-Boosted-Bootstrap"
Expand Down
2 changes: 1 addition & 1 deletion js/src/dom/manipulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Manipulator = {

for (const key of bsKeys) {
let pureKey = key.replace(/^bs/, '')
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length)
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1)
attributes[pureKey] = normalizeData(element.dataset[key])
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class Dropdown extends BaseComponent {

return {
...defaultBsPopperConfig,
...execute(this._config.popperConfig, [defaultBsPopperConfig])
...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
}
}

Expand Down
5 changes: 2 additions & 3 deletions js/src/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ class Tooltip extends BaseComponent {
return
}

this._activeTrigger.click = !this._activeTrigger.click
if (this._isShown()) {
this._leave()
return
Expand Down Expand Up @@ -392,7 +391,7 @@ class Tooltip extends BaseComponent {
}

_resolvePossibleFunction(arg) {
return execute(arg, [this._element])
return execute(arg, [this._element, this._element])
}

_getPopperConfig(attachment) {
Expand Down Expand Up @@ -438,7 +437,7 @@ class Tooltip extends BaseComponent {

return {
...defaultBsPopperConfig,
...execute(this._config.popperConfig, [defaultBsPopperConfig])
...execute(this._config.popperConfig, [undefined, defaultBsPopperConfig])
}
}

Expand Down
2 changes: 1 addition & 1 deletion js/src/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ const defineJQueryPlugin = plugin => {
}

const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue
return typeof possibleCallback === 'function' ? possibleCallback.call(...args) : defaultValue
}

const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
Expand Down
2 changes: 1 addition & 1 deletion js/src/util/template-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class TemplateFactory extends Config {
}

_resolvePossibleFunction(arg) {
return execute(arg, [this])
return execute(arg, [undefined, this])
}

_putElementInTemplate(element, templateElement) {
Expand Down
5 changes: 4 additions & 1 deletion js/tests/unit/dropdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ describe('Dropdown', () => {

const popperConfig = dropdown._getPopperConfig()

expect(getPopperConfig).toHaveBeenCalled()
// Ensure that the function was called with the default config.
expect(getPopperConfig).toHaveBeenCalledWith(jasmine.objectContaining({
placement: jasmine.any(String)
}))
expect(popperConfig.placement).toEqual('left')
})
})
Expand Down
74 changes: 74 additions & 0 deletions js/tests/unit/popover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ describe('Popover', () => {
})

describe('show', () => {
it('should toggle a popover after show', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" title="Popover" data-bs-content="https://twitter.com/getbootstrap">BS twitter</a>'

const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl)

popoverEl.addEventListener('shown.bs.popover', () => {
expect(document.querySelector('.popover')).not.toBeNull()
popover.toggle()
})
popoverEl.addEventListener('hidden.bs.popover', () => {
expect(document.querySelector('.popover')).toBeNull()
resolve()
})

popover.show()
})
})

it('should show a popover', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" title="Popover" data-bs-content="https://twitter.com/getbootstrap">BS twitter</a>'
Expand Down Expand Up @@ -95,6 +115,60 @@ describe('Popover', () => {
})
})

it('should call content and title functions with trigger element', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" data-foo="bar">BS twitter</a>'

const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl, {
title(el) {
return el.dataset.foo
},
content(el) {
return el.dataset.foo
}
})

popoverEl.addEventListener('shown.bs.popover', () => {
const popoverDisplayed = document.querySelector('.popover')

expect(popoverDisplayed).not.toBeNull()
expect(popoverDisplayed.querySelector('.popover-header').textContent).toEqual('bar')
expect(popoverDisplayed.querySelector('.popover-body').textContent).toEqual('bar')
resolve()
})

popover.show()
})
})

it('should call content and title functions with correct this value', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" data-foo="bar">BS twitter</a>'

const popoverEl = fixtureEl.querySelector('a')
const popover = new Popover(popoverEl, {
title() {
return this.dataset.foo
},
content() {
return this.dataset.foo
}
})

popoverEl.addEventListener('shown.bs.popover', () => {
const popoverDisplayed = document.querySelector('.popover')

expect(popoverDisplayed).not.toBeNull()
expect(popoverDisplayed.querySelector('.popover-header').textContent).toEqual('bar')
expect(popoverDisplayed.querySelector('.popover-body').textContent).toEqual('bar')
resolve()
})

popover.show()
})
})

it('should show a popover with just content without having header', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#">Nice link</a>'
Expand Down
40 changes: 36 additions & 4 deletions js/tests/unit/tooltip.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ describe('Tooltip', () => {

const popperConfig = tooltip._getPopperConfig('top')

expect(getPopperConfig).toHaveBeenCalled()
// Ensure that the function was called with the default config.
expect(getPopperConfig).toHaveBeenCalledWith(jasmine.objectContaining({
placement: jasmine.any(String)
}))
expect(popperConfig.placement).toEqual('left')
})

Expand Down Expand Up @@ -919,10 +922,12 @@ describe('Tooltip', () => {

it('should show a tooltip with custom class provided as a function in config', () => {
return new Promise(resolve => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip"></a>'
fixtureEl.innerHTML = '<a href="#" rel="tooltip" title="Another tooltip" data-class-a="custom-class-a" data-class-b="custom-class-b"></a>'

const spy = jasmine.createSpy('customClass').and.returnValue('custom-class')
const tooltipEl = fixtureEl.querySelector('a')
const spy = jasmine.createSpy('customClass').and.callFake(function (el) {
return `${el.dataset.classA} ${this.dataset.classB}`
})
const tooltip = new Tooltip(tooltipEl, {
customClass: spy
})
Expand All @@ -931,7 +936,8 @@ describe('Tooltip', () => {
const tip = document.querySelector('.tooltip')
expect(tip).not.toBeNull()
expect(spy).toHaveBeenCalled()
expect(tip).toHaveClass('custom-class')
expect(tip).toHaveClass('custom-class-a')
expect(tip).toHaveClass('custom-class-b')
resolve()
})

Expand Down Expand Up @@ -1337,6 +1343,32 @@ describe('Tooltip', () => {

expect(tooltip._getTitle()).toEqual('test')
})

it('should call title function with trigger element', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" data-foo="bar"></a>'

const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
title(el) {
return el.dataset.foo
}
})

expect(tooltip._getTitle()).toEqual('bar')
})

it('should call title function with correct this value', () => {
fixtureEl.innerHTML = '<a href="#" rel="tooltip" data-foo="bar"></a>'

const tooltipEl = fixtureEl.querySelector('a')
const tooltip = new Tooltip(tooltipEl, {
title() {
return this.dataset.foo
}
})

expect(tooltip._getTitle()).toEqual('bar')
})
})

describe('getInstance', () => {
Expand Down
4 changes: 2 additions & 2 deletions js/tests/unit/util/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,10 @@ describe('Util', () => {

it('should execute if arg is function & return the result', () => {
const functionFoo = (num1, num2 = 10) => num1 + num2
const resultFoo = Util.execute(functionFoo, [4, 5])
const resultFoo = Util.execute(functionFoo, [undefined, 4, 5])
expect(resultFoo).toBe(9)

const resultFoo1 = Util.execute(functionFoo, [4])
const resultFoo1 = Util.execute(functionFoo, [undefined, 4])
expect(resultFoo1).toBe(14)

const functionBar = () => 'foo'
Expand Down
Loading
Loading