|
1 | 1 |
|
2 | 2 | interface Cash { |
3 | | - [index: number]: EleAll; |
4 | | - length: number; |
5 | | - splice ( start: number, deleteCount?: number ): Ele[]; |
6 | | - splice ( start: number, deleteCount: number, ...items: Ele[] ): Ele[]; |
| 3 | + [index: number]: EleLoose, |
| 4 | + length: number, |
| 5 | + splice ( start: number, deleteCount?: number ): Ele[], |
| 6 | + splice ( start: number, deleteCount: number, ...items: Ele[] ): Ele[] |
7 | 7 | } |
8 | 8 |
|
9 | 9 | interface CashStatic { |
10 | | - fn: Cash; |
| 10 | + fn: Cash |
11 | 11 | } |
12 | 12 |
|
13 | 13 | type plainObject = { [index: string]: any }; |
14 | 14 | type falsy = undefined | null | false | 0 | ''; |
15 | 15 |
|
16 | 16 | type Ele = Window | Document | HTMLElement | Element | Node; |
17 | | -type EleAll = Window & Document & HTMLElement & Element & Node; //UGLY: Trick to remove some kind-of useless type errors //URL: https://github.com/kenwheeler/cash/issues/278 |
| 17 | +type EleLoose = Window & Document & HTMLElement & Element & Node; //UGLY: Trick to remove some kind-of useless type errors //URL: https://github.com/kenwheeler/cash/issues/278 |
18 | 18 | type Selector = falsy | string | Function | HTMLCollection | NodeList | Ele | Ele[] | ArrayLike<Ele> | Cash; |
19 | 19 | type Comparator = string | Ele | Cash | (( this: Ele, index: number, ele: Ele ) => boolean); |
20 | 20 | type Context = Document | HTMLElement | Element; |
@@ -173,10 +173,10 @@ Cash.prototype.last = function ( this: Cash ) { |
173 | 173 | type MapCallback<T> = ( this: T, index: number, ele: T ) => Ele; |
174 | 174 |
|
175 | 175 | interface Cash { |
176 | | - map ( callback: MapCallback<Ele> ): Cash; |
| 176 | + map ( callback: MapCallback<EleLoose> ): Cash; |
177 | 177 | } |
178 | 178 |
|
179 | | -Cash.prototype.map = function ( this: Cash, callback: MapCallback<Ele> ) { |
| 179 | +Cash.prototype.map = function ( this: Cash, callback: MapCallback<EleLoose> ) { |
180 | 180 | return cash ( map.call ( this, ( ele: Ele, i: number ) => callback.call ( ele, i, ele ) ) ); |
181 | 181 | }; |
182 | 182 |
|
@@ -237,10 +237,10 @@ cash.each = each; |
237 | 237 | // @require core/each.ts |
238 | 238 |
|
239 | 239 | interface Cash { |
240 | | - each ( callback: EachCallback<Ele> ): this; |
| 240 | + each ( callback: EachCallback<EleLoose> ): this; |
241 | 241 | } |
242 | 242 |
|
243 | | -Cash.prototype.each = function ( this: Cash, callback: EachCallback<Ele> ) { |
| 243 | +Cash.prototype.each = function ( this: Cash, callback: EachCallback<EleLoose> ) { |
244 | 244 | each ( this, callback ); |
245 | 245 | return this; |
246 | 246 | }; |
@@ -1074,9 +1074,9 @@ Cash.prototype.toggle = function ( this: Cash, force?: boolean ) { |
1074 | 1074 |
|
1075 | 1075 | return this.each ( ( i, ele ) => { |
1076 | 1076 |
|
1077 | | - force = force !== undefined ? force : isHidden ( ele ); |
| 1077 | + const show = force !== undefined ? force : isHidden ( ele ); |
1078 | 1078 |
|
1079 | | - if ( force ) { |
| 1079 | + if ( show ) { |
1080 | 1080 |
|
1081 | 1081 | ele.style.display = ''; |
1082 | 1082 |
|
@@ -2517,3 +2517,4 @@ Cash.prototype.siblings = function ( this: Cash, comparator?: Comparator ) { |
2517 | 2517 | // @require ./cash.ts |
2518 | 2518 |
|
2519 | 2519 | export default cash; |
| 2520 | +export { Cash, Ele as Element, Selector, Comparator, Context }; |
0 commit comments