A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/bootstrap-vue/bootstrap-vue/commit/31eeb0ab5ef262c33579f43969c7d6ee6c802e3d below:

fix `title` not being reset on hide (#5793) · bootstrap-vue/bootstrap-vue@31eeb0a · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+99

-6

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+99

-6

lines changed Original file line number Diff line number Diff line change

@@ -621,19 +621,31 @@ export const BVTooltip = /*#__PURE__*/ Vue.extend({

621 621

}

622 622

},

623 623

fixTitle() {

624 -

// If the target has a `title` attribute, remove it and store it on a data attribute

624 +

// If the target has a `title` attribute,

625 +

// remove it and store it on a data attribute

625 626

const target = this.getTarget()

626 -

if (target && hasAttr(target, 'title')) {

627 -

setAttr(target, DATA_TITLE_ATTR, getAttr(target, 'title') || '')

627 +

if (hasAttr(target, 'title')) {

628 +

// Get `title` attribute value and remove it from target

629 +

const title = getAttr(target, 'title')

628 630

setAttr(target, 'title', '')

631 +

// Only set the data attribute when the value is truthy

632 +

if (title) {

633 +

setAttr(target, DATA_TITLE_ATTR, title)

634 +

}

629 635

}

630 636

},

631 637

restoreTitle() {

632 -

// If the target had a title, restore it and remove the data attribute

638 +

// If the target had a `title` attribute,

639 +

// restore it and remove the data attribute

633 640

const target = this.getTarget()

634 -

if (target && hasAttr(target, DATA_TITLE_ATTR)) {

635 -

setAttr(target, 'title', getAttr(target, DATA_TITLE_ATTR) || '')

641 +

if (hasAttr(target, DATA_TITLE_ATTR)) {

642 +

// Get data attribute value and remove it from target

643 +

const title = getAttr(target, DATA_TITLE_ATTR)

636 644

removeAttr(target, DATA_TITLE_ATTR)

645 +

// Only restore the `title` attribute when the value is truthy

646 +

if (title) {

647 +

setAttr(target, 'title', title)

648 +

}

637 649

}

638 650

},

639 651

// --- BvEvent helpers ---

Original file line number Diff line number Diff line change

@@ -1445,4 +1445,85 @@ describe('b-tooltip', () => {

1445 1445 1446 1446

wrapper.destroy()

1447 1447

})

1448 + 1449 +

it('saves title in data attribute on open and adds to back on hide', async () => {

1450 +

jest.useFakeTimers()

1451 +

const wrapper = mount(App, {

1452 +

attachTo: createContainer(),

1453 +

propsData: {

1454 +

triggers: 'click',

1455 +

show: false,

1456 +

titleAttr: 'bar'

1457 +

},

1458 +

slots: {

1459 +

default: 'title'

1460 +

}

1461 +

})

1462 + 1463 +

expect(wrapper.vm).toBeDefined()

1464 +

await waitNT(wrapper.vm)

1465 +

await waitRAF()

1466 +

await waitNT(wrapper.vm)

1467 +

await waitRAF()

1468 +

jest.runOnlyPendingTimers()

1469 + 1470 +

expect(wrapper.element.tagName).toBe('ARTICLE')

1471 +

expect(wrapper.attributes('id')).toBeDefined()

1472 +

expect(wrapper.attributes('id')).toEqual('wrapper')

1473 + 1474 +

// The trigger button

1475 +

const $button = wrapper.find('button')

1476 +

expect($button.exists()).toBe(true)

1477 +

expect($button.attributes('id')).toBeDefined()

1478 +

expect($button.attributes('id')).toEqual('foo')

1479 +

expect($button.attributes('title')).toBeDefined()

1480 +

expect($button.attributes('title')).toEqual('bar')

1481 +

expect($button.attributes('data-original-title')).not.toBeDefined()

1482 +

expect($button.attributes('aria-describedby')).not.toBeDefined()

1483 + 1484 +

// Show tooltip

1485 +

await wrapper.setProps({ show: true })

1486 + 1487 +

expect($button.attributes('title')).toBeDefined()

1488 +

expect($button.attributes('title')).toEqual('')

1489 +

expect($button.attributes('data-original-title')).toBeDefined()

1490 +

expect($button.attributes('data-original-title')).toEqual('bar')

1491 +

expect($button.attributes('aria-describedby')).toBeDefined()

1492 +

// ID of the tooltip that will be in the body

1493 +

const adb = $button.attributes('aria-describedby')

1494 + 1495 +

// <b-tooltip> wrapper

1496 +

const $tipHolder = wrapper.findComponent(BTooltip)

1497 +

expect($tipHolder.exists()).toBe(true)

1498 +

expect($tipHolder.element.nodeType).toEqual(Node.COMMENT_NODE)

1499 + 1500 +

// Find the tooltip element in the document

1501 +

const tip = document.getElementById(adb)

1502 +

expect(tip).not.toBe(null)

1503 +

expect(tip).toBeInstanceOf(HTMLElement)

1504 +

expect(tip.tagName).toEqual('DIV')

1505 +

expect(tip.classList.contains('tooltip')).toBe(true)

1506 +

expect(tip.classList.contains('b-tooltip')).toBe(true)

1507 +

expect(tip.classList.contains('interactive')).toBe(false)

1508 +

expect(tip.textContent).toEqual('title')

1509 + 1510 +

// Hide the tooltip

1511 +

await wrapper.setProps({ show: false })

1512 +

await waitRAF()

1513 +

await waitRAF()

1514 +

jest.runOnlyPendingTimers()

1515 +

await waitNT(wrapper.vm)

1516 +

await waitRAF()

1517 + 1518 +

expect($button.attributes('title')).toBeDefined()

1519 +

expect($button.attributes('title')).toEqual('bar')

1520 +

expect($button.attributes('data-original-title')).not.toBeDefined()

1521 +

expect($button.attributes('aria-describedby')).not.toBeDefined()

1522 + 1523 +

// Tooltip element should not be in the document

1524 +

expect(document.body.contains(tip)).toBe(false)

1525 +

expect(document.querySelector(adb)).toBe(null)

1526 + 1527 +

wrapper.destroy()

1528 +

})

1448 1529

})

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4