Skip to content

Commit d34b00b

Browse files
committed
fix: revert default element typings to HTMLElement
The type definitions were updated to allow generic element typing in #1871 However, this "loosened" the default type from `HTMLElement` to `Element. This was actually a breaking change. For example, consumers may have had this test code: ```ts wrapper.element.click() ``` But `click()` only exists on `HTMLElement`, not on `Element`, so test compilation fails. This change moves the default type back to `HTMLElement`. If we want to loosen this requirement in the future, it should be considered a breaking change.
1 parent d56d945 commit d34b00b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/test-utils/types/index.d.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@ interface BaseWrapper {
7575
selector: Selector | void
7676
}
7777

78-
export interface Wrapper<V extends Vue | null, el extends Element = Element> extends BaseWrapper {
78+
export interface Wrapper<V extends Vue | null, el extends HTMLElement = HTMLElement> extends BaseWrapper {
7979
readonly vm: V
8080
readonly element: el
8181
readonly options: WrapperOptions
8282

8383
get<R extends Vue> (selector: VueClass<R>): Wrapper<R>
8484
get<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
8585
get<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(selector: FunctionalComponentOptions<Props, PropDefs>): Wrapper<Vue>
86-
get<el extends Element>(selector: string): Wrapper<Vue, el>
86+
get<el extends HTMLElement>(selector: string): Wrapper<Vue, el>
8787
get (selector: RefSelector): Wrapper<Vue>
8888
get (selector: NameSelector): Wrapper<Vue>
8989

@@ -96,7 +96,7 @@ export interface Wrapper<V extends Vue | null, el extends Element = Element> ext
9696
find<R extends Vue> (selector: VueClass<R>): Wrapper<R>
9797
find<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
9898
find<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(selector: FunctionalComponentOptions<Props, PropDefs>): Wrapper<Vue>
99-
find<el extends Element>(selector: string): Wrapper<Vue, el>
99+
find<el extends HTMLElement>(selector: string): Wrapper<Vue, el>
100100
find (selector: RefSelector): Wrapper<Vue>
101101
find (selector: NameSelector): Wrapper<Vue>
102102

packages/test-utils/types/test/wrapper.ts

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ found = wrapper.find({ name: 'my-button' })
6969
selector = found.selector
7070

7171
wrapper.find<HTMLInputElement>('input').element.value
72+
wrapper.find('div').element.click()
7273

7374
let array = wrapper.findAll('.bar')
7475
selector = array.selector

0 commit comments

Comments
 (0)