mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 05:06:55 +04:00
Fix data attributes written with data-tblr- instead of data-bs- (#3219)
This commit is contained in:
1 parent
e3da90ecb6
commit
29818fcc83
4 files changed
+11
-7
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@tabler/core": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fixed `Manipulator.setDataAttribute()` writing `data-tblr-*` attributes instead of `data-bs-*`.
|
||||||
@@ -43,7 +43,7 @@ const PREFIXES = ['tblr', 'bs'] as const
|
|||||||
|
|
||||||
const Manipulator = {
|
const Manipulator = {
|
||||||
setDataAttribute(element: HTMLElement, key: string, value: string): void {
|
setDataAttribute(element: HTMLElement, key: string, value: string): void {
|
||||||
element.setAttribute(`data-tblr-${normalizeDataKey(key)}`, value)
|
element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value)
|
||||||
},
|
},
|
||||||
|
|
||||||
removeDataAttribute(element: HTMLElement, key: string): void {
|
removeDataAttribute(element: HTMLElement, key: string): void {
|
||||||
|
|||||||
@@ -20,23 +20,23 @@ describe('Manipulator', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('setDataAttribute', () => {
|
describe('setDataAttribute', () => {
|
||||||
it('should set a data-tblr-* attribute', () => {
|
it('should set a data-bs-* attribute', () => {
|
||||||
Manipulator.setDataAttribute(div, 'key', 'value')
|
Manipulator.setDataAttribute(div, 'key', 'value')
|
||||||
|
|
||||||
expect(div.getAttribute('data-tblr-key')).toBe('value')
|
expect(div.getAttribute('data-bs-key')).toBe('value')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should convert camelCase keys to kebab-case', () => {
|
it('should convert camelCase keys to kebab-case', () => {
|
||||||
Manipulator.setDataAttribute(div, 'testKey', '123')
|
Manipulator.setDataAttribute(div, 'testKey', '123')
|
||||||
|
|
||||||
expect(div.getAttribute('data-tblr-test-key')).toBe('123')
|
expect(div.getAttribute('data-bs-test-key')).toBe('123')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should overwrite existing value', () => {
|
it('should overwrite existing value', () => {
|
||||||
Manipulator.setDataAttribute(div, 'key', 'old')
|
Manipulator.setDataAttribute(div, 'key', 'old')
|
||||||
Manipulator.setDataAttribute(div, 'key', 'new')
|
Manipulator.setDataAttribute(div, 'key', 'new')
|
||||||
|
|
||||||
expect(div.getAttribute('data-tblr-key')).toBe('new')
|
expect(div.getAttribute('data-bs-key')).toBe('new')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -660,8 +660,7 @@ Navbar vertical
|
|||||||
// The sidebar is rendered for the expanded state, so the active submenu can
|
// The sidebar is rendered for the expanded state, so the active submenu can
|
||||||
// arrive open (.show). Folded, it would paint as a flyout until sidebar.ts
|
// arrive open (.show). Folded, it would paint as a flyout until sidebar.ts
|
||||||
// closes it on DOMContentLoaded — a flicker on every reload. Menus opened by
|
// closes it on DOMContentLoaded — a flicker on every reload. Menus opened by
|
||||||
// the Dropdown plugin carry a popper data attribute (data-tblr-popper from
|
// the Dropdown plugin carry a data-bs-popper attribute, so only the
|
||||||
// tabler.js, data-bs-popper from Bootstrap's own js), so only the
|
|
||||||
// server-rendered ones hide.
|
// server-rendered ones hide.
|
||||||
.navbar-vertical .dropdown-menu.show:not([data-bs-popper]):not([data-tblr-popper]) {
|
.navbar-vertical .dropdown-menu.show:not([data-bs-popper]):not([data-tblr-popper]) {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
Reference in new issue
Block a user