Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,9 @@ describe('VListItem.ts', () => {

const listItem = wrapper.findComponent(VListItem)

;(listItem.vm.$refs.link as any)._vnode = {
data: {
class: { 'v-list-item--active': true }
}
}
const linkRef = listItem.vm.$refs.link as any
const linkEl = linkRef.$el || linkRef
linkEl.classList.add('v-list-item--active')

listItem.vm.onRouteChange()
await nextTick()
Expand Down
8 changes: 3 additions & 5 deletions packages/vuetify/src/components/VTabs/__tests__/VTab.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ describe('VTab.ts', () => {
// explicitly mock class added
// by vue router
if (wrapper.vm.$refs.link) {
(wrapper.vm.$refs.link as any)._vnode = {
data: {
class: { 'bar v-tab--active': true }
}
}
const linkRef = wrapper.vm.$refs.link as any
const linkEl = linkRef.$el || linkRef
linkEl.classList.add('bar', 'v-tab--active')
}
(wrapper.vm as any).$route.path = '/foo'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,8 @@ describe('routable.ts', () => {

expect(toggle).not.toHaveBeenCalled()

;(wrapper.vm.$refs.link as any)._vnode = {
data: {
class: { 'bar v-tab--active': true }
}
}
const linkEl = wrapper.vm.$refs.link as HTMLElement
linkEl.classList.add('bar', 'v-tab--active')

wrapper.vm.onRouteChange()
await nextTick()
Expand Down
7 changes: 4 additions & 3 deletions packages/vuetify/src/mixins/routable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { defineComponent, resolveComponent } from 'vue'
import Ripple, { RippleOptions } from '../../directives/ripple'

// Utilities
import { getObjectValueByPath } from '../../util/helpers'

export default defineComponent({
name: 'routable',
Expand Down Expand Up @@ -148,11 +147,13 @@ export default defineComponent({
const activeClass = `${this.activeClass || ''} ${this.proxyClass || ''}`.trim()
const exactActiveClass = `${this.exactActiveClass || ''} ${this.proxyClass || ''}`.trim() || activeClass

const path = '_vnode.data.class.' + (this.exact ? exactActiveClass : activeClass)
const activeClasses = (this.exact ? exactActiveClass : activeClass).split(' ')

this.$nextTick(() => {
/* istanbul ignore else */
const isLinkActive = Boolean(getObjectValueByPath(this.$refs.link, path))
const el = (this.$refs.link as any).$el || this.$refs.link
const isLinkActive = activeClasses.every(c => el?.classList?.contains(c))

if (isLinkActive !== this.isActive) {
this.toggle()
}
Expand Down
Loading