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

Fix [SliderThumb]: Vue Compat: deprecation INSTANCE_ATTRS_CLASS_STYLE (#16) #216

Merged
merged 3 commits into from
Mar 29, 2024
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

* `SliderThumb`:

TBD
If `compat-fallthrough` is `true`, the attributes fall through to the root `<div>` element, otherwise to the inner `<div>` element.

* `Table`:

Expand Down
55 changes: 55 additions & 0 deletions packages/buefy-next/src/components/slider/SliderThumb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,59 @@ describe('BSliderThumb', () => {
await wrapper.setProps({ tooltipAlways: true })
expect(wrapper.findComponent(BTooltip).props().always).toBe(true)
})

describe('with fallthrough attributes', () => {
const attrs = {
class: 'fallthrough-class',
style: 'font-size: 2rem;',
id: 'fallthrough-id'
}

it('should apply class, style, and id to the root <div> element if compatFallthrough is true (default)', () => {
const wrapper = shallowMount(BSliderThumb, {
attrs,
global: {
stubs: {
// b-tooltip must be rendered to access the inner <div>
'b-tooltip': false
}
}
})

const root = wrapper.find('div.b-slider-thumb-wrapper')
expect(root.classes(attrs.class)).toBe(true)
expect(root.attributes('style')).toBe(attrs.style)
expect(root.attributes('id')).toBe(attrs.id)

const inner = wrapper.find('div.b-slider-thumb')
expect(inner.classes(attrs.class)).toBe(false)
expect(inner.attributes('style')).toBeUndefined()
expect(inner.attributes('id')).toBeUndefined()
})

it('should apply class, style, and id to the inner <div> element if compatFallthrough is false', () => {
const wrapper = shallowMount(BSliderThumb, {
attrs,
props: {
compatFallthrough: false
},
global: {
stubs: {
// b-tooltip must be rendered to access the inner <div>
'b-tooltip': false
}
}
})

const root = wrapper.find('div.b-slider-thumb-wrapper')
expect(root.classes(attrs.class)).toBe(false)
expect(root.attributes('style')).toBeUndefined()
expect(root.attributes('id')).toBeUndefined()

const inner = wrapper.find('div.b-slider-thumb')
expect(inner.classes(attrs.class)).toBe(true)
expect(inner.attributes('style')).toBe(attrs.style)
expect(inner.attributes('id')).toBe(attrs.id)
})
})
})
6 changes: 4 additions & 2 deletions packages/buefy-next/src/components/slider/SliderThumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class="b-slider-thumb-wrapper"
:class="{ 'is-dragging': dragging, 'has-indicator': indicator}"
:style="wrapperStyle"
v-bind="rootAttrs"
>
<b-tooltip
:label="formattedValue"
Expand All @@ -13,7 +14,7 @@
<div
class="b-slider-thumb"
:tabindex="disabled ? false : 0"
v-bind="$attrs"
v-bind="fallthroughAttrs"
@mousedown="onButtonDown"
@touchstart="onButtonDown"
@focus="onFocus"
Expand All @@ -34,13 +35,14 @@
<script>
import Tooltip from '../tooltip/Tooltip.vue'
import config from '../../utils/config'
import CompatFallthroughMixin from '../../utils/CompatFallthroughMixin'

export default {
name: 'BSliderThumb',
components: {
[Tooltip.name]: Tooltip
},
inheritAttrs: false,
mixins: [CompatFallthroughMixin],
props: {
modelValue: {
type: Number,
Expand Down