Skip to content

Commit 71e8ea1

Browse files
committed
feat(VDatePicker): Add data-today attribute for identifying today's date
1 parent acff32f commit 71e8ea1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/vuetify/src/components/VDatePicker/VDatePickerMonth.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export const VDatePickerMonth = genericComponent<VDatePickerMonthSlots>()({
211211
},
212212
]}
213213
data-v-date={ !item.isDisabled ? item.isoDate : undefined }
214+
data-today={ item.isToday ? 'true' : undefined }
214215
>
215216

216217
{ (props.showAdjacentMonths || !item.isAdjacent) && (

packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.month.spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -351,4 +351,20 @@ describe.skip('VDatePicker.ts', () => {
351351
expect(wrapper.findAll('.v-date-picker-table--month tbody button.v-date-picker--last-in-range')
352352
.exists()).toBe(true)
353353
})
354+
355+
it('adds data-today attribute to the correct date element', async () => {
356+
const wrapper = mountFunction({
357+
propsData: {
358+
value: '2025-02',
359+
type: 'month',
360+
},
361+
})
362+
363+
// Find the element that represents today's date
364+
const todayElement = wrapper.find('[data-today="true"]')
365+
366+
// Assertions
367+
expect(todayElement.exists()).toBe(true) // It should exist
368+
expect(todayElement.attributes('data-today')).toBe('true') // Check attribute value
369+
})
354370
})

0 commit comments

Comments
 (0)