@dimailn/vuetify 2.7.2-alpha56 → 2.7.2-alpha58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/json/attributes.json +3945 -417
- package/dist/json/tags.json +1120 -133
- package/dist/json/web-types.json +12516 -2651
- package/dist/vuetify.js +93 -102
- package/dist/vuetify.js.map +1 -1
- package/dist/vuetify.min.css +1 -1
- package/dist/vuetify.min.js +2 -2
- package/es5/directives/click-outside/index.js +19 -21
- package/es5/directives/click-outside/index.js.map +1 -1
- package/es5/directives/intersect/index.js +12 -17
- package/es5/directives/intersect/index.js.map +1 -1
- package/es5/directives/mutate/index.js +9 -11
- package/es5/directives/mutate/index.js.map +1 -1
- package/es5/directives/resize/index.js +8 -10
- package/es5/directives/resize/index.js.map +1 -1
- package/es5/directives/scroll/index.js +11 -12
- package/es5/directives/scroll/index.js.map +1 -1
- package/es5/directives/touch/index.js +6 -5
- package/es5/directives/touch/index.js.map +1 -1
- package/es5/framework.js +1 -1
- package/es5/mixins/overlayable/index.js +27 -26
- package/es5/mixins/overlayable/index.js.map +1 -1
- package/es5/services/theme/utils.js.map +1 -1
- package/lib/directives/click-outside/index.js +17 -19
- package/lib/directives/click-outside/index.js.map +1 -1
- package/lib/directives/intersect/index.js +12 -16
- package/lib/directives/intersect/index.js.map +1 -1
- package/lib/directives/mutate/index.js +9 -11
- package/lib/directives/mutate/index.js.map +1 -1
- package/lib/directives/resize/index.js +8 -8
- package/lib/directives/resize/index.js.map +1 -1
- package/lib/directives/scroll/index.js +8 -8
- package/lib/directives/scroll/index.js.map +1 -1
- package/lib/directives/touch/index.js +6 -5
- package/lib/directives/touch/index.js.map +1 -1
- package/lib/framework.js +1 -1
- package/lib/mixins/overlayable/index.js +28 -27
- package/lib/mixins/overlayable/index.js.map +1 -1
- package/lib/services/theme/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/components/VMenu/__tests__/VMenuActivatorTest.spec.ts +25 -0
- package/src/components/VMenu/__tests__/test-with-directives.spec.ts +50 -0
- package/src/directives/click-outside/__tests__/click-outside-shadow-dom.spec.ts +2 -1
- package/src/directives/click-outside/__tests__/click-outside.spec.ts +2 -1
- package/src/directives/click-outside/index.ts +25 -18
- package/src/directives/intersect/__tests__/intersect.spec.ts +31 -13
- package/src/directives/intersect/index.ts +15 -19
- package/src/directives/mutate/__tests__/mutate.spec.ts +35 -27
- package/src/directives/mutate/index.ts +12 -6
- package/src/directives/resize/__tests__/resize.spec.ts +4 -4
- package/src/directives/resize/index.ts +11 -18
- package/src/directives/scroll/__tests__/scroll.spec.ts +5 -29
- package/src/directives/scroll/index.ts +14 -7
- package/src/directives/touch/index.ts +6 -5
- package/src/mixins/overlayable/__tests__/overlayable.spec.ts +24 -0
- package/src/mixins/overlayable/index.ts +25 -23
- package/src/services/theme/utils.ts +1 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// Directives
|
|
2
2
|
import Mutate from '../'
|
|
3
3
|
|
|
4
|
+
const observers: any[] = [];
|
|
5
|
+
|
|
4
6
|
(global as any).MutationObserver = class { // Mock MutationObserver
|
|
5
7
|
_callback: Function
|
|
6
|
-
|
|
7
8
|
_observe = jest.fn()
|
|
9
|
+
disconnect = jest.fn()
|
|
8
10
|
|
|
9
11
|
constructor (callback) {
|
|
10
12
|
this._callback = callback
|
|
13
|
+
observers.push(this)
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
disconnect () {}
|
|
14
|
-
|
|
15
16
|
observe (_, options) {
|
|
16
17
|
this._observe(options)
|
|
17
18
|
}
|
|
@@ -22,26 +23,30 @@ import Mutate from '../'
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
describe('mutate.ts', () => {
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
observers.length = 0
|
|
28
|
+
})
|
|
29
|
+
|
|
25
30
|
it('should bind event on inserted', () => {
|
|
26
31
|
const callback = jest.fn()
|
|
27
32
|
const el = document.createElement('div') as any
|
|
28
33
|
document.body.appendChild(el)
|
|
29
34
|
|
|
30
35
|
Mutate.mounted(el, {
|
|
36
|
+
instance: { $: { uid: 1 } },
|
|
31
37
|
value: callback
|
|
32
|
-
} as any, {
|
|
38
|
+
} as any, {} as any)
|
|
33
39
|
|
|
34
|
-
expect(
|
|
40
|
+
expect(observers).toHaveLength(1)
|
|
35
41
|
expect(callback).not.toHaveBeenCalled()
|
|
36
42
|
|
|
37
43
|
document.body.removeChild(el)
|
|
38
44
|
|
|
39
45
|
Mutate.unmounted(el, {
|
|
46
|
+
instance: { $: { uid: 1 } },
|
|
40
47
|
value: callback
|
|
41
|
-
} as any, {
|
|
42
|
-
|
|
43
|
-
const uid = Object.keys(el._mutate)[0]
|
|
44
|
-
expect(el._mutate[uid]).toBeFalsy()
|
|
48
|
+
} as any, {} as any)
|
|
49
|
+
expect(observers[0].disconnect).toHaveBeenCalled()
|
|
45
50
|
})
|
|
46
51
|
|
|
47
52
|
it('should fire event on mutation', () => {
|
|
@@ -50,19 +55,20 @@ describe('mutate.ts', () => {
|
|
|
50
55
|
document.body.appendChild(el)
|
|
51
56
|
|
|
52
57
|
Mutate.mounted(el, {
|
|
58
|
+
instance: { $: { uid: 1 } },
|
|
53
59
|
value: callback
|
|
54
|
-
} as any, {
|
|
60
|
+
} as any, {} as any)
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
el._mutate[uid]?.observer?.trigger([{}])
|
|
62
|
+
observers[0]?.trigger([{} as any])
|
|
58
63
|
|
|
59
64
|
expect(callback).toHaveBeenCalledTimes(1)
|
|
60
65
|
|
|
61
66
|
document.body.removeChild(el)
|
|
62
67
|
|
|
63
68
|
Mutate.unmounted(el, {
|
|
69
|
+
instance: { $: { uid: 1 } },
|
|
64
70
|
value: callback
|
|
65
|
-
} as any, {
|
|
71
|
+
} as any, {} as any)
|
|
66
72
|
})
|
|
67
73
|
|
|
68
74
|
it('should fire event once', () => {
|
|
@@ -71,18 +77,18 @@ describe('mutate.ts', () => {
|
|
|
71
77
|
document.body.appendChild(el)
|
|
72
78
|
|
|
73
79
|
Mutate.mounted(el, {
|
|
80
|
+
instance: { $: { uid: 1 } },
|
|
74
81
|
value: callback,
|
|
75
82
|
modifiers: {
|
|
76
83
|
once: true
|
|
77
84
|
}
|
|
78
|
-
} as any, {
|
|
85
|
+
} as any, {} as any)
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
el._mutate[uid]?.observer?.trigger([{}])
|
|
87
|
+
observers[0]?.trigger([{} as any])
|
|
82
88
|
|
|
83
89
|
expect(callback).toHaveBeenCalledTimes(1)
|
|
84
90
|
// Once modifier should remove the observer
|
|
85
|
-
expect(
|
|
91
|
+
expect(observers[0].disconnect).toHaveBeenCalled()
|
|
86
92
|
|
|
87
93
|
document.body.removeChild(el)
|
|
88
94
|
})
|
|
@@ -93,6 +99,7 @@ describe('mutate.ts', () => {
|
|
|
93
99
|
document.body.appendChild(el)
|
|
94
100
|
|
|
95
101
|
Mutate.mounted(el, {
|
|
102
|
+
instance: { $: { uid: 1 } },
|
|
96
103
|
value: {
|
|
97
104
|
options: {
|
|
98
105
|
attributes: false,
|
|
@@ -100,17 +107,17 @@ describe('mutate.ts', () => {
|
|
|
100
107
|
},
|
|
101
108
|
handler: callback
|
|
102
109
|
}
|
|
103
|
-
} as any, {
|
|
110
|
+
} as any, {} as any)
|
|
104
111
|
|
|
105
|
-
|
|
106
|
-
el._mutate[uid]?.observer?.trigger([{}])
|
|
112
|
+
observers[0]?.trigger([{} as any])
|
|
107
113
|
|
|
108
114
|
expect(callback).toHaveBeenCalledTimes(1)
|
|
109
|
-
expect(
|
|
115
|
+
expect(observers[0]._observe).toHaveBeenLastCalledWith({ attributes: false, subtree: true })
|
|
110
116
|
|
|
111
117
|
document.body.removeChild(el)
|
|
112
118
|
|
|
113
119
|
Mutate.unmounted(el, {
|
|
120
|
+
instance: { $: { uid: 1 } },
|
|
114
121
|
value: {
|
|
115
122
|
options: {
|
|
116
123
|
attributes: false,
|
|
@@ -118,7 +125,7 @@ describe('mutate.ts', () => {
|
|
|
118
125
|
},
|
|
119
126
|
handler: callback
|
|
120
127
|
}
|
|
121
|
-
} as any, {
|
|
128
|
+
} as any, {} as any)
|
|
122
129
|
})
|
|
123
130
|
|
|
124
131
|
it('should work with observer modifiers', () => {
|
|
@@ -127,29 +134,30 @@ describe('mutate.ts', () => {
|
|
|
127
134
|
document.body.appendChild(el)
|
|
128
135
|
|
|
129
136
|
Mutate.mounted(el, {
|
|
137
|
+
instance: { $: { uid: 1 } },
|
|
130
138
|
value: callback,
|
|
131
139
|
modifiers: {
|
|
132
140
|
attr: true,
|
|
133
141
|
child: true,
|
|
134
142
|
sub: true
|
|
135
143
|
}
|
|
136
|
-
} as any, {
|
|
144
|
+
} as any, {} as any)
|
|
137
145
|
|
|
138
|
-
|
|
139
|
-
el._mutate[uid]?.observer?.trigger([{}])
|
|
146
|
+
observers[0]?.trigger([{} as any])
|
|
140
147
|
|
|
141
148
|
expect(callback).toHaveBeenCalledTimes(1)
|
|
142
|
-
expect(
|
|
149
|
+
expect(observers[0]._observe).toHaveBeenLastCalledWith({ attributes: true, childList: true, subtree: true })
|
|
143
150
|
|
|
144
151
|
document.body.removeChild(el)
|
|
145
152
|
|
|
146
153
|
Mutate.unmounted(el, {
|
|
154
|
+
instance: { $: { uid: 1 } },
|
|
147
155
|
value: callback,
|
|
148
156
|
modifiers: {
|
|
149
157
|
attr: true,
|
|
150
158
|
child: true,
|
|
151
159
|
sub: true
|
|
152
160
|
}
|
|
153
|
-
} as any, {
|
|
161
|
+
} as any, {} as any)
|
|
154
162
|
})
|
|
155
163
|
})
|
|
@@ -17,6 +17,12 @@ type MutateModifiers = {
|
|
|
17
17
|
char?: boolean
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
+
interface MutateState {
|
|
21
|
+
observer: MutationObserver
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const mutateState = new WeakMap<HTMLElement, MutateState>()
|
|
25
|
+
|
|
20
26
|
function mounted (
|
|
21
27
|
el: HTMLElement,
|
|
22
28
|
binding: DirectiveBinding<MutateValue>,
|
|
@@ -51,7 +57,7 @@ function mounted (
|
|
|
51
57
|
const observer = new MutationObserver(
|
|
52
58
|
(mutationsList: MutationRecord[], observer: MutationObserver) => {
|
|
53
59
|
/* istanbul ignore if */
|
|
54
|
-
if (!el
|
|
60
|
+
if (!mutateState.has(el)) return // Just in case, should never fire
|
|
55
61
|
|
|
56
62
|
callback(mutationsList, observer)
|
|
57
63
|
|
|
@@ -61,8 +67,7 @@ function mounted (
|
|
|
61
67
|
)
|
|
62
68
|
|
|
63
69
|
observer.observe(el, options)
|
|
64
|
-
el
|
|
65
|
-
el._mutate![vnode.ctx!.uid] = { observer }
|
|
70
|
+
mutateState.set(el, { observer })
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
function unmounted (
|
|
@@ -70,10 +75,11 @@ function unmounted (
|
|
|
70
75
|
binding: DirectiveBinding<MutateValue>,
|
|
71
76
|
vnode: VNode
|
|
72
77
|
) {
|
|
73
|
-
|
|
78
|
+
const state = mutateState.get(el)
|
|
79
|
+
if (!state) return
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
delete
|
|
81
|
+
state.observer.disconnect()
|
|
82
|
+
mutateState.delete(el)
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
export const Mutate = {
|
|
@@ -8,10 +8,10 @@ describe('resize.ts', () => {
|
|
|
8
8
|
jest.spyOn(window, 'removeEventListener')
|
|
9
9
|
const el = {}
|
|
10
10
|
|
|
11
|
-
Resize.mounted(el as HTMLElement, {
|
|
11
|
+
Resize.mounted(el as HTMLElement, { instance: { $: { uid: 1 } }, value: callback } as any, {} as any)
|
|
12
12
|
expect(callback).toHaveBeenCalled()
|
|
13
13
|
expect(window.addEventListener).toHaveBeenCalledWith('resize', callback, { passive: true })
|
|
14
|
-
Resize.unmounted(el as HTMLElement, {
|
|
14
|
+
Resize.unmounted(el as HTMLElement, { instance: { $: { uid: 1 } }, value: callback } as any, {} as any)
|
|
15
15
|
expect(window.removeEventListener).toHaveBeenCalledWith('resize', callback, { passive: true })
|
|
16
16
|
})
|
|
17
17
|
|
|
@@ -21,10 +21,10 @@ describe('resize.ts', () => {
|
|
|
21
21
|
jest.spyOn(window, 'removeEventListener')
|
|
22
22
|
const el = {}
|
|
23
23
|
|
|
24
|
-
Resize.mounted(el as HTMLElement, { value: callback, modifiers: { quiet: true } } as any, {
|
|
24
|
+
Resize.mounted(el as HTMLElement, { instance: { $: { uid: 1 } }, value: callback, modifiers: { quiet: true } } as any, {} as any)
|
|
25
25
|
expect(callback).not.toHaveBeenCalled()
|
|
26
26
|
expect(window.addEventListener).toHaveBeenCalledWith('resize', callback, { passive: true })
|
|
27
|
-
Resize.unmounted(el as HTMLElement, { value: callback, modifiers: { quiet: true } } as any, {
|
|
27
|
+
Resize.unmounted(el as HTMLElement, { instance: { $: { uid: 1 } }, value: callback, modifiers: { quiet: true } } as any, {} as any)
|
|
28
28
|
expect(window.removeEventListener).toHaveBeenCalledWith('resize', callback, { passive: true })
|
|
29
29
|
})
|
|
30
30
|
})
|
|
@@ -5,18 +5,13 @@ interface ResizeDirectiveBinding extends DirectiveBinding {
|
|
|
5
5
|
options?: boolean | AddEventListenerOptions
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
number,
|
|
12
|
-
{
|
|
13
|
-
callback: () => void
|
|
14
|
-
options: boolean | AddEventListenerOptions
|
|
15
|
-
}
|
|
16
|
-
>
|
|
17
|
-
}
|
|
8
|
+
interface ResizeState {
|
|
9
|
+
callback: () => void
|
|
10
|
+
options: boolean | AddEventListenerOptions
|
|
18
11
|
}
|
|
19
12
|
|
|
13
|
+
const resizeState = new WeakMap<HTMLElement, ResizeState>()
|
|
14
|
+
|
|
20
15
|
function mounted (
|
|
21
16
|
el: HTMLElement,
|
|
22
17
|
binding: ResizeDirectiveBinding,
|
|
@@ -27,11 +22,10 @@ function mounted (
|
|
|
27
22
|
|
|
28
23
|
window.addEventListener('resize', callback, options)
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
el._onResize![vnode.ctx!.uid] = {
|
|
25
|
+
resizeState.set(el, {
|
|
32
26
|
callback,
|
|
33
27
|
options
|
|
34
|
-
}
|
|
28
|
+
})
|
|
35
29
|
|
|
36
30
|
if (!binding.modifiers || !binding.modifiers.quiet) {
|
|
37
31
|
callback()
|
|
@@ -43,13 +37,12 @@ function unmounted (
|
|
|
43
37
|
binding: ResizeDirectiveBinding,
|
|
44
38
|
vnode: VNode
|
|
45
39
|
) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const { callback, options } =
|
|
40
|
+
const state = resizeState.get(el)
|
|
41
|
+
if (!state) return
|
|
42
|
+
const { callback, options } = state
|
|
49
43
|
|
|
50
44
|
window.removeEventListener('resize', callback, options)
|
|
51
|
-
|
|
52
|
-
delete el._onResize[vnode.ctx!.uid]
|
|
45
|
+
resizeState.delete(el)
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
export const Resize: ObjectDirective = {
|
|
@@ -12,9 +12,10 @@ describe('scroll.ts', () => {
|
|
|
12
12
|
let vnode
|
|
13
13
|
|
|
14
14
|
beforeEach(() => {
|
|
15
|
-
vnode = {
|
|
15
|
+
vnode = {} as any
|
|
16
16
|
options = { passive: true }
|
|
17
17
|
binding = {
|
|
18
|
+
instance: { $: { uid: 1 } },
|
|
18
19
|
value: jest.fn(),
|
|
19
20
|
modifiers: {},
|
|
20
21
|
arg: null
|
|
@@ -32,16 +33,10 @@ describe('scroll.ts', () => {
|
|
|
32
33
|
mounted(el, binding, vnode)
|
|
33
34
|
|
|
34
35
|
expect(spyOnWindowAddListener).toHaveBeenCalledWith('scroll', binding.value, options)
|
|
35
|
-
expect(el._onScroll[1]).toEqual({
|
|
36
|
-
handler: binding.value,
|
|
37
|
-
options,
|
|
38
|
-
target: window
|
|
39
|
-
})
|
|
40
36
|
|
|
41
37
|
unmounted(el, binding, vnode)
|
|
42
38
|
|
|
43
39
|
expect(spyOnWindowRemoveListener).toHaveBeenCalledWith('scroll', binding.value, options)
|
|
44
|
-
expect(el._onScroll[1]).toBeUndefined()
|
|
45
40
|
})
|
|
46
41
|
|
|
47
42
|
it('should work with a provided valid querySelector string', () => {
|
|
@@ -66,16 +61,10 @@ describe('scroll.ts', () => {
|
|
|
66
61
|
mounted(el, binding, vnode)
|
|
67
62
|
|
|
68
63
|
expect(spyOnFooAddListener).toHaveBeenCalledWith('scroll', binding.value, options)
|
|
69
|
-
expect(el._onScroll[1]).toEqual({
|
|
70
|
-
handler: binding.value,
|
|
71
|
-
options,
|
|
72
|
-
target
|
|
73
|
-
})
|
|
74
64
|
|
|
75
65
|
unmounted(el, binding, vnode)
|
|
76
66
|
|
|
77
67
|
expect(spyOnFooRemoveListener).toHaveBeenCalledWith('scroll', binding.value, options)
|
|
78
|
-
expect(el._onScroll[1]).toBeUndefined()
|
|
79
68
|
|
|
80
69
|
document.body.removeChild(target)
|
|
81
70
|
})
|
|
@@ -86,16 +75,10 @@ describe('scroll.ts', () => {
|
|
|
86
75
|
mounted(el, binding, vnode)
|
|
87
76
|
|
|
88
77
|
expect(el.addEventListener).toHaveBeenCalledWith('scroll', binding.value, options)
|
|
89
|
-
expect(el._onScroll[1]).toEqual({
|
|
90
|
-
handler: binding.value,
|
|
91
|
-
options,
|
|
92
|
-
target: undefined
|
|
93
|
-
})
|
|
94
78
|
|
|
95
79
|
unmounted(el, binding, vnode)
|
|
96
80
|
|
|
97
81
|
expect(el.removeEventListener).toHaveBeenCalledWith('scroll', binding.value, options)
|
|
98
|
-
expect(el._onScroll[1]).toBeUndefined()
|
|
99
82
|
})
|
|
100
83
|
|
|
101
84
|
it('should not remove listeners if no _onScroll property present', () => {
|
|
@@ -106,25 +89,18 @@ describe('scroll.ts', () => {
|
|
|
106
89
|
|
|
107
90
|
it('should accept an object for the value with handler and/or options', () => {
|
|
108
91
|
const handler = binding.value
|
|
92
|
+
jest.spyOn(window, 'addEventListener')
|
|
109
93
|
|
|
110
94
|
binding.value = { handler }
|
|
111
95
|
|
|
112
96
|
mounted(el, binding, vnode)
|
|
113
97
|
|
|
114
|
-
expect(
|
|
115
|
-
handler,
|
|
116
|
-
target: window,
|
|
117
|
-
options: { passive: true }
|
|
118
|
-
})
|
|
98
|
+
expect(window.addEventListener).toHaveBeenLastCalledWith('scroll', handler, { passive: true })
|
|
119
99
|
|
|
120
100
|
binding.value = { handler, options: { passive: false } }
|
|
121
101
|
|
|
122
102
|
mounted(el, binding, vnode)
|
|
123
103
|
|
|
124
|
-
expect(
|
|
125
|
-
handler,
|
|
126
|
-
target: window,
|
|
127
|
-
options: { passive: false }
|
|
128
|
-
})
|
|
104
|
+
expect(window.addEventListener).toHaveBeenLastCalledWith('scroll', handler, { passive: false })
|
|
129
105
|
})
|
|
130
106
|
})
|
|
@@ -13,6 +13,14 @@ interface ScrollDirectiveBinding extends Omit<DirectiveBinding, 'modifiers'> {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
interface ScrollState {
|
|
17
|
+
handler: EventListener | EventListenerObject
|
|
18
|
+
options: boolean | AddEventListenerOptions
|
|
19
|
+
target?: EventTarget
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const scrollState = new WeakMap<HTMLElement, ScrollState>()
|
|
23
|
+
|
|
16
24
|
function mounted (
|
|
17
25
|
el: HTMLElement,
|
|
18
26
|
binding: ScrollDirectiveBinding,
|
|
@@ -38,13 +46,12 @@ function mounted (
|
|
|
38
46
|
|
|
39
47
|
target.addEventListener('scroll', handler, options)
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
el._onScroll![vnode.ctx!.uid] = {
|
|
49
|
+
scrollState.set(el, {
|
|
43
50
|
handler,
|
|
44
51
|
options,
|
|
45
52
|
// Don't reference self
|
|
46
53
|
target: self ? undefined : target
|
|
47
|
-
}
|
|
54
|
+
})
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
function unmounted (
|
|
@@ -52,12 +59,12 @@ function unmounted (
|
|
|
52
59
|
binding: ScrollDirectiveBinding,
|
|
53
60
|
vnode: VNode
|
|
54
61
|
) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const { handler, options, target = el } =
|
|
62
|
+
const state = scrollState.get(el)
|
|
63
|
+
if (!state) return
|
|
64
|
+
const { handler, options, target = el } = state
|
|
58
65
|
|
|
59
66
|
target.removeEventListener('scroll', handler, options)
|
|
60
|
-
delete
|
|
67
|
+
scrollState.delete(el)
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
export const Scroll: ObjectDirective = {
|
|
@@ -85,6 +85,8 @@ function createHandlers (value: TouchHandlers): TouchStoredHandlers {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
const touchState = new WeakMap<EventTarget, TouchStoredHandlers>()
|
|
89
|
+
|
|
88
90
|
function mounted (
|
|
89
91
|
el: HTMLElement,
|
|
90
92
|
binding: DirectiveBinding<TouchValue>,
|
|
@@ -98,8 +100,7 @@ function mounted (
|
|
|
98
100
|
if (!target) return
|
|
99
101
|
|
|
100
102
|
const handlers = createHandlers(binding.value)
|
|
101
|
-
|
|
102
|
-
target._touchHandlers![vnode.ctx!.uid] = handlers
|
|
103
|
+
touchState.set(target, handlers)
|
|
103
104
|
|
|
104
105
|
keys(handlers).forEach(eventName => {
|
|
105
106
|
target.addEventListener(
|
|
@@ -116,14 +117,14 @@ function unmounted (
|
|
|
116
117
|
vnode: VNode
|
|
117
118
|
) {
|
|
118
119
|
const target = binding.value.parent ? el.parentElement : el
|
|
119
|
-
if (!target
|
|
120
|
+
if (!target) return
|
|
120
121
|
|
|
121
|
-
const handlers = target
|
|
122
|
+
const handlers = touchState.get(target)
|
|
122
123
|
if (handlers) {
|
|
123
124
|
keys(handlers).forEach(eventName => {
|
|
124
125
|
target.removeEventListener(eventName, handlers[eventName])
|
|
125
126
|
})
|
|
126
|
-
delete
|
|
127
|
+
touchState.delete(target)
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
|
|
@@ -75,6 +75,12 @@ describe('Overlayable.ts', () => {
|
|
|
75
75
|
expect(wrapper.vm.overlay).toBeFalsy()
|
|
76
76
|
})
|
|
77
77
|
|
|
78
|
+
it('destroyOverlay безопасен когда оверлея нет', () => {
|
|
79
|
+
const wrapper = mountFunction()
|
|
80
|
+
expect(() => wrapper.vm.destroyOverlay()).not.toThrow()
|
|
81
|
+
expect(wrapper.vm.overlay).toBeFalsy()
|
|
82
|
+
})
|
|
83
|
+
|
|
78
84
|
it('should remove overlay app container after close', async () => {
|
|
79
85
|
const wrapper = mountFunction()
|
|
80
86
|
|
|
@@ -210,6 +216,24 @@ describe('Overlayable.ts', () => {
|
|
|
210
216
|
expect(wrapper.vm.overlay!.$el.isConnected).toBe(true)
|
|
211
217
|
})
|
|
212
218
|
|
|
219
|
+
it('beforeUnmount уничтожает оверлей даже при isActive (фикс залипшего overlay)', async () => {
|
|
220
|
+
const wrapper = mountDrawerLike()
|
|
221
|
+
|
|
222
|
+
wrapper.vm.temporary = true
|
|
223
|
+
wrapper.vm.isActive = true
|
|
224
|
+
await nextTick()
|
|
225
|
+
await waitAnimationFrame()
|
|
226
|
+
|
|
227
|
+
const app = document.querySelector('[data-app]') as HTMLElement
|
|
228
|
+
expect(app.querySelector('.v-overlay')).toBeTruthy()
|
|
229
|
+
expect(document.querySelectorAll('[data-v-app]')).toHaveLength(1)
|
|
230
|
+
|
|
231
|
+
wrapper.unmount()
|
|
232
|
+
|
|
233
|
+
expect(app.querySelector('.v-overlay')).toBeNull()
|
|
234
|
+
expect(document.querySelectorAll('[data-v-app]')).toHaveLength(0)
|
|
235
|
+
})
|
|
236
|
+
|
|
213
237
|
it('showOverlay true→true не вызывает genOverlay после потери [data-app]', async () => {
|
|
214
238
|
const genOverlay = jest.fn()
|
|
215
239
|
const removeOverlay = jest.fn()
|
|
@@ -57,7 +57,7 @@ export default defineComponent({
|
|
|
57
57
|
},
|
|
58
58
|
|
|
59
59
|
beforeUnmount () {
|
|
60
|
-
this.
|
|
60
|
+
this.destroyOverlay()
|
|
61
61
|
},
|
|
62
62
|
|
|
63
63
|
methods: {
|
|
@@ -113,14 +113,7 @@ export default defineComponent({
|
|
|
113
113
|
if (this.hideOverlay) return
|
|
114
114
|
|
|
115
115
|
if (!this.overlay?.$el?.isConnected) {
|
|
116
|
-
|
|
117
|
-
cancelAnimationFrame(this.animationFrame)
|
|
118
|
-
const container = this.overlay.$el?.parentNode as HTMLElement | null
|
|
119
|
-
this.overlayApp?.unmount()
|
|
120
|
-
this.overlayApp = null
|
|
121
|
-
if (container?.parentNode) container.parentNode.removeChild(container)
|
|
122
|
-
this.overlay = null
|
|
123
|
-
}
|
|
116
|
+
this.teardownOverlay()
|
|
124
117
|
this.createOverlay()
|
|
125
118
|
}
|
|
126
119
|
|
|
@@ -142,10 +135,7 @@ export default defineComponent({
|
|
|
142
135
|
removeOverlay (showScroll = true) {
|
|
143
136
|
if (this.overlay) {
|
|
144
137
|
if (!this.overlay.$el?.isConnected) {
|
|
145
|
-
|
|
146
|
-
this.overlayApp?.unmount()
|
|
147
|
-
this.overlayApp = null
|
|
148
|
-
this.overlay = null
|
|
138
|
+
this.teardownOverlay()
|
|
149
139
|
showScroll && this.showScroll()
|
|
150
140
|
return
|
|
151
141
|
}
|
|
@@ -159,16 +149,7 @@ export default defineComponent({
|
|
|
159
149
|
this.isActive
|
|
160
150
|
) return
|
|
161
151
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
this.overlayApp?.unmount()
|
|
165
|
-
this.overlayApp = null
|
|
166
|
-
|
|
167
|
-
if (overlayContainer?.parentNode) {
|
|
168
|
-
overlayContainer.parentNode.removeChild(overlayContainer)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
this.overlay = null
|
|
152
|
+
this.teardownOverlay()
|
|
172
153
|
})
|
|
173
154
|
|
|
174
155
|
// Cancel animation frame in case
|
|
@@ -181,6 +162,27 @@ export default defineComponent({
|
|
|
181
162
|
|
|
182
163
|
showScroll && this.showScroll()
|
|
183
164
|
},
|
|
165
|
+
teardownOverlay () {
|
|
166
|
+
cancelAnimationFrame(this.animationFrame)
|
|
167
|
+
|
|
168
|
+
if (!this.overlay) return
|
|
169
|
+
|
|
170
|
+
const container = this.overlay.$el?.parentNode as HTMLElement | null
|
|
171
|
+
|
|
172
|
+
this.overlayApp?.unmount()
|
|
173
|
+
this.overlayApp = null
|
|
174
|
+
|
|
175
|
+
if (container?.parentNode) {
|
|
176
|
+
container.parentNode.removeChild(container)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this.overlay = null
|
|
180
|
+
},
|
|
181
|
+
/** Синхронно уничтожает оверлей независимо от isActive/анимации. Для unmount. */
|
|
182
|
+
destroyOverlay () {
|
|
183
|
+
this.teardownOverlay()
|
|
184
|
+
this.showScroll()
|
|
185
|
+
},
|
|
184
186
|
scrollListener (e: WheelEvent | KeyboardEvent) {
|
|
185
187
|
if ('key' in e) {
|
|
186
188
|
if (
|
|
@@ -100,7 +100,7 @@ export function genStyles (theme: VuetifyParsedTheme, cssVar = false): string {
|
|
|
100
100
|
|
|
101
101
|
const variants = keys(value)
|
|
102
102
|
for (let i = 0; i < variants.length; ++i) {
|
|
103
|
-
const variant = variants[i]
|
|
103
|
+
const variant = variants[i] as string
|
|
104
104
|
const variantValue = value[variant]
|
|
105
105
|
if (variant === 'base') continue
|
|
106
106
|
|