File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,13 @@ export class DOMWrapper<ElementType extends Element> {
18
18
return Array . from ( classes )
19
19
}
20
20
21
- attributes ( key ?: string ) {
21
+ attributes ( ) : { [ key : string ] : string }
22
+ attributes ( key : string ) : string
23
+ attributes ( key ?: string ) : { [ key : string ] : string } | string {
22
24
const attributes = this . element . attributes
23
- const attributeMap = { }
25
+ const attributeMap : { [ key : string ] : string } = { }
24
26
for ( let i = 0 ; i < attributes . length ; i ++ ) {
25
- const att = attributes . item ( i )
27
+ const att = attributes . item ( i ) !
26
28
attributeMap [ att . localName ] = att . value
27
29
}
28
30
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ export class VueWrapper<T extends ComponentPublicInstance> {
54
54
return new DOMWrapper ( this . element ) . classes ( className )
55
55
}
56
56
57
- attributes ( key ?: string ) {
57
+ attributes ( ) : { [ key : string ] : string }
58
+ attributes ( key : string ) : string
59
+ attributes ( key ?: string ) : { [ key : string ] : string } | string {
58
60
return new DOMWrapper ( this . element ) . attributes ( key )
59
61
}
60
62
Original file line number Diff line number Diff line change @@ -86,3 +86,9 @@ expectType<SVGLineElement>(line.element)
86
86
// string selector
87
87
byClass = domWrapper . get ( '.todo' )
88
88
expectType < Element > ( byClass . element )
89
+
90
+ // attributes
91
+ expectType < { [ key : string ] : string } > ( wrapper . attributes ( ) )
92
+ expectType < string > ( wrapper . attributes ( 'key' ) )
93
+ expectType < { [ key : string ] : string } > ( domWrapper . attributes ( ) )
94
+ expectType < string > ( domWrapper . attributes ( 'key' ) )
You can’t perform that action at this time.
0 commit comments