Skip to content

Commit e856ceb

Browse files
Bumped version to 5.0.0
1 parent fed591f commit e856ceb

8 files changed

Lines changed: 1340 additions & 1457 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
### Version 5.0.0
2+
- Dropped support for IE10
3+
- $.fn.hasClass: ensuring it always returns a boolean
4+
- $.fn.off: accepting also an events map as its only argument
5+
- $.fn.show|toggle: restoring custom display values
6+
- $.fn.before|after|append|prepend|insertBefore|insertAfter|appendTo|prependTo: ensuring multiple nodes are inserted in the correct order
7+
- Ensuring attached events never get forgotten
8+
- Ensuring script tags are executed even if they have a “src” attribute, and without using `eval`
9+
- Ensuring the order of event namespaces doesn’t matter
10+
- Squeezed some more bytes out of the bundle (~4%) and improved code style consistency
11+
- Squeezed some more bytes out of the bundle (~1.5%), bringing back the minified and gzipped size below 5kb
12+
113
### Version 4.1.5
214
- $.fn.val: ensuring it works with “input[type=file][multiple]” elements
315
- Migration guide: mentioning how $.fn.data stores values

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ If you're migrating from jQuery be sure to read our [migration guide](https://gi
3030

3131
## Usage
3232

33-
Get Cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/4.1.5/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@4.1.5/dist/cash.min.js) and use it like this:
33+
Get Cash from [CloudFlare](https://cdnjs.cloudflare.com/ajax/libs/cash/5.0.0/cash.min.js) or [jsDelivr](https://cdn.jsdelivr.net/npm/cash-dom@5.0.0/dist/cash.min.js) and use it like this:
3434

3535
```html
36-
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/4.1.5/cash.min.js"></script>
36+
<script src="https://cdnjs.cloudflare.com/ajax/libs/cash/5.0.0/cash.min.js"></script>
3737
<script>
3838
$(function () {
3939
$('html').addClass ( 'dom-loaded' );

dist/cash.d.ts

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
interface Event {
2+
namespace: string;
3+
data: any;
4+
___cd?: boolean;
5+
}
16
interface Cash {
27
[index: number]: EleLoose | undefined;
38
length: number;
@@ -7,17 +12,14 @@ interface Cash {
712
interface CashStatic {
813
fn: Cash;
914
}
10-
declare type plainObject = {
11-
[index: string]: any;
12-
};
1315
declare type falsy = undefined | null | false | 0 | '';
1416
declare type EleHTML = HTMLElement | HTMLAnchorElement | HTMLAppletElement | HTMLAreaElement | HTMLAudioElement | HTMLBRElement | HTMLBaseElement | HTMLBaseFontElement | HTMLBodyElement | HTMLButtonElement | HTMLCanvasElement | HTMLDListElement | HTMLDataElement | HTMLDataListElement | HTMLDetailsElement | HTMLDialogElement | HTMLDirectoryElement | HTMLDivElement | HTMLEmbedElement | HTMLFieldSetElement | HTMLFontElement | HTMLFormElement | HTMLFrameElement | HTMLFrameSetElement | HTMLHRElement | HTMLHeadElement | HTMLHeadingElement | HTMLHtmlElement | HTMLIFrameElement | HTMLImageElement | HTMLInputElement | HTMLLIElement | HTMLLabelElement | HTMLLegendElement | HTMLLinkElement | HTMLMapElement | HTMLMarqueeElement | HTMLMediaElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLModElement | HTMLOListElement | HTMLObjectElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOrSVGElement | HTMLOutputElement | HTMLParagraphElement | HTMLParamElement | HTMLPictureElement | HTMLPreElement | HTMLProgressElement | HTMLQuoteElement | HTMLScriptElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLSpanElement | HTMLStyleElement | HTMLTableCaptionElement | HTMLTableCellElement | HTMLTableColElement | HTMLTableDataCellElement | HTMLTableElement | HTMLTableHeaderCellElement | HTMLTableRowElement | HTMLTableSectionElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTimeElement | HTMLTitleElement | HTMLTrackElement | HTMLUListElement | HTMLUnknownElement | HTMLVideoElement;
1517
declare type EleHTMLLoose = HTMLElement & HTMLAnchorElement & HTMLAppletElement & HTMLAreaElement & HTMLAudioElement & HTMLBRElement & HTMLBaseElement & HTMLBaseFontElement & HTMLBodyElement & HTMLButtonElement & HTMLCanvasElement & HTMLDListElement & HTMLDataElement & HTMLDataListElement & HTMLDetailsElement & HTMLDialogElement & HTMLDirectoryElement & HTMLDivElement & HTMLEmbedElement & HTMLFieldSetElement & HTMLFontElement & HTMLFormElement & HTMLFrameElement & HTMLFrameSetElement & HTMLHRElement & HTMLHeadElement & HTMLHeadingElement & HTMLHtmlElement & HTMLIFrameElement & HTMLImageElement & HTMLInputElement & HTMLLIElement & HTMLLabelElement & HTMLLegendElement & HTMLLinkElement & HTMLMapElement & HTMLMarqueeElement & HTMLMediaElement & HTMLMenuElement & HTMLMetaElement & HTMLMeterElement & HTMLModElement & HTMLOListElement & HTMLObjectElement & HTMLOptGroupElement & HTMLOptionElement & HTMLOrSVGElement & HTMLOutputElement & HTMLParagraphElement & HTMLParamElement & HTMLPictureElement & HTMLPreElement & HTMLProgressElement & HTMLQuoteElement & HTMLScriptElement & HTMLSelectElement & HTMLSlotElement & HTMLSourceElement & HTMLSpanElement & HTMLStyleElement & HTMLTableCaptionElement & HTMLTableCellElement & HTMLTableColElement & HTMLTableDataCellElement & HTMLTableElement & HTMLTableHeaderCellElement & HTMLTableRowElement & HTMLTableSectionElement & HTMLTemplateElement & HTMLTextAreaElement & HTMLTimeElement & HTMLTitleElement & HTMLTrackElement & HTMLUListElement & HTMLUnknownElement & HTMLVideoElement;
1618
declare type Ele = Window | Document | EleHTML | Element | Node;
1719
declare type EleLoose = Window & Document & EleHTMLLoose & Element & Node;
1820
declare type Selector = falsy | string | Function | HTMLCollection | NodeList | Ele | Ele[] | ArrayLike<Ele> | Cash;
19-
declare type Comparator = string | Ele | Cash | ((this: Ele, index: number, ele: Ele) => boolean);
20-
declare type Context = Document | HTMLElement | Element;
21+
declare type Comparator = string | Ele | Cash | ((this: EleLoose, index: number, ele: EleLoose) => boolean);
22+
declare type Context = Document | EleHTML | Element;
2123
declare type EventCallback = {
2224
(event: any, data?: any): any;
2325
guid?: number;
@@ -26,20 +28,7 @@ declare class Cash {
2628
constructor(selector?: Selector, context?: Context | Cash);
2729
init(selector?: Selector, context?: Context | Cash): Cash;
2830
}
29-
declare const cash: ((selector?: Selector, context?: Element | HTMLElement | Document | Cash) => Cash) & CashStatic;
30-
interface Cash {
31-
get(): EleLoose[];
32-
get(index: number): EleLoose | undefined;
33-
}
34-
interface Cash {
35-
eq(index: number): Cash;
36-
}
37-
interface Cash {
38-
first(): Cash;
39-
}
40-
interface Cash {
41-
last(): Cash;
42-
}
31+
declare const cash: ((selector?: Selector, context?: Element | HTMLMediaElement | HTMLElement | HTMLOrSVGElement | HTMLCanvasElement | HTMLImageElement | HTMLVideoElement | Document | HTMLAnchorElement | HTMLAppletElement | HTMLScriptElement | HTMLEmbedElement | HTMLFormElement | HTMLHeadElement | HTMLAreaElement | HTMLObjectElement | HTMLLinkElement | HTMLTrackElement | HTMLProgressElement | HTMLAudioElement | HTMLBaseElement | HTMLBaseFontElement | HTMLQuoteElement | HTMLBodyElement | HTMLBRElement | HTMLButtonElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLDataElement | HTMLDataListElement | HTMLModElement | HTMLDetailsElement | HTMLDialogElement | HTMLDirectoryElement | HTMLDivElement | HTMLDListElement | HTMLFieldSetElement | HTMLFontElement | HTMLFrameElement | HTMLFrameSetElement | HTMLHeadingElement | HTMLHRElement | HTMLHtmlElement | HTMLIFrameElement | HTMLInputElement | HTMLLabelElement | HTMLLegendElement | HTMLLIElement | HTMLMapElement | HTMLMarqueeElement | HTMLMenuElement | HTMLMetaElement | HTMLMeterElement | HTMLOListElement | HTMLOptGroupElement | HTMLOptionElement | HTMLOutputElement | HTMLParagraphElement | HTMLParamElement | HTMLPictureElement | HTMLPreElement | HTMLSelectElement | HTMLSlotElement | HTMLSourceElement | HTMLSpanElement | HTMLStyleElement | HTMLTableElement | HTMLTableSectionElement | HTMLTableDataCellElement | HTMLTableCellElement | HTMLTemplateElement | HTMLTextAreaElement | HTMLTableHeaderCellElement | HTMLTimeElement | HTMLTitleElement | HTMLTableRowElement | HTMLUListElement | HTMLUnknownElement | Cash) => Cash) & CashStatic;
4332
declare type MapCallback<T> = (this: T, index: number, ele: T) => Ele;
4433
interface Cash {
4534
map(callback: MapCallback<EleLoose>): Cash;
@@ -60,12 +49,12 @@ interface Cash {
6049
interface Cash {
6150
removeProp(prop: string): this;
6251
}
63-
interface Cash {
64-
extend(plugins: plainObject): this;
65-
}
6652
interface CashStatic {
6753
extend(target: any, ...objs: any[]): any;
6854
}
55+
interface Cash {
56+
extend(plugins: Record<any, any>): this;
57+
}
6958
interface CashStatic {
7059
guid: number;
7160
}
@@ -82,10 +71,23 @@ interface CashStatic {
8271
interface Cash {
8372
prop(prop: string): any;
8473
prop(prop: string, value: any): this;
85-
prop(props: plainObject): this;
74+
prop(props: Record<string, any>): this;
75+
}
76+
interface Cash {
77+
get(): EleLoose[];
78+
get(index: number): EleLoose | undefined;
79+
}
80+
interface Cash {
81+
eq(index: number): Cash;
82+
}
83+
interface Cash {
84+
first(): Cash;
85+
}
86+
interface Cash {
87+
last(): Cash;
8688
}
8789
interface Cash {
88-
filter(comparator: Comparator): Cash;
90+
filter(comparator?: Comparator): Cash;
8991
}
9092
interface Cash {
9193
hasClass(cls: string): boolean;
@@ -97,7 +99,7 @@ interface Cash {
9799
attr(): undefined;
98100
attr(attrs: string): string | null;
99101
attr(attrs: string, value: string): this;
100-
attr(attrs: plainObject): this;
102+
attr(attrs: Record<string, string>): this;
101103
}
102104
interface Cash {
103105
toggleClass(classes: string, force?: boolean): this;
@@ -119,29 +121,27 @@ interface CashStatic {
119121
}
120122
interface Cash {
121123
css(prop: string): string | undefined;
122-
css(prop: string, value: string): this;
123-
css(props: plainObject): this;
124+
css(prop: string, value: number | string): this;
125+
css(props: Record<string, number | string>): this;
124126
}
125127
interface Cash {
126-
data(): plainObject | undefined;
128+
data(): Record<string, any> | undefined;
127129
data(name: string): any;
128130
data(name: string, value: any): this;
129-
data(datas: plainObject): this;
131+
data(datas: Record<string, any>): this;
130132
}
131133
interface Cash {
132134
innerWidth(): number | undefined;
133135
innerHeight(): number | undefined;
136+
outerWidth(includeMargins?: boolean): number;
137+
outerHeight(includeMargins?: boolean): number;
134138
}
135139
interface Cash {
136140
width(): number;
137141
width(value: number | string): this;
138142
height(): number;
139143
height(value: number | string): this;
140144
}
141-
interface Cash {
142-
outerWidth(includeMargins?: boolean): number;
143-
outerHeight(includeMargins?: boolean): number;
144-
}
145145
interface Cash {
146146
toggle(force?: boolean): this;
147147
}
@@ -154,16 +154,17 @@ interface Cash {
154154
interface Cash {
155155
off(): this;
156156
off(events: string): this;
157+
off(events: Record<string, EventCallback>): this;
157158
off(events: string, callback: EventCallback): this;
158159
off(events: string, selector: string, callback: EventCallback): this;
159160
}
160161
interface Cash {
161-
on(events: plainObject): this;
162+
on(events: Record<string, EventCallback>): this;
162163
on(events: string, callback: EventCallback, _one?: boolean): this;
163164
on(events: string, selector: string | EventCallback, callback: EventCallback, _one?: boolean): this;
164165
}
165166
interface Cash {
166-
one(events: plainObject): this;
167+
one(events: Record<string, EventCallback>): this;
167168
one(events: string, callback: EventCallback): this;
168169
one(events: string, selector: string | EventCallback, callback: EventCallback): this;
169170
}
@@ -187,7 +188,7 @@ interface Cash {
187188
detach(): this;
188189
}
189190
interface CashStatic {
190-
parseHTML(html: string): Ele[];
191+
parseHTML(html: string): EleLoose[];
191192
}
192193
interface Cash {
193194
empty(): this;
@@ -230,24 +231,24 @@ interface Cash {
230231
interface Cash {
231232
find(selector: string): Cash;
232233
}
234+
interface Cash {
235+
after(...selectors: Selector[]): this;
236+
}
233237
interface Cash {
234238
append(...selectors: Selector[]): this;
235239
}
236240
interface Cash {
237241
appendTo(selector: Selector): this;
238242
}
239243
interface Cash {
240-
insertAfter(selector: Selector): this;
244+
before(...selectors: Selector[]): this;
241245
}
242246
interface Cash {
243-
after(...selectors: Selector[]): this;
247+
insertAfter(selector: Selector): this;
244248
}
245249
interface Cash {
246250
insertBefore(selector: Selector): this;
247251
}
248-
interface Cash {
249-
before(...selectors: Selector[]): this;
250-
}
251252
interface Cash {
252253
prepend(...selectors: Selector[]): this;
253254
}
@@ -270,10 +271,10 @@ interface Cash {
270271
wrapInner(selector?: Selector): this;
271272
}
272273
interface Cash {
273-
has(selector: string | HTMLElement): Cash;
274+
has(selector: string | Node): Cash;
274275
}
275276
interface Cash {
276-
is(comparator: Comparator): boolean;
277+
is(comparator?: Comparator): boolean;
277278
}
278279
interface Cash {
279280
next(comparator?: Comparator, _all?: boolean): Cash;
@@ -282,7 +283,7 @@ interface Cash {
282283
nextAll(comparator?: Comparator): Cash;
283284
}
284285
interface Cash {
285-
not(comparator: Comparator): Cash;
286+
not(comparator?: Comparator): Cash;
286287
}
287288
interface Cash {
288289
parent(comparator?: Comparator): Cash;
@@ -291,7 +292,7 @@ interface Cash {
291292
index(selector?: Selector): number;
292293
}
293294
interface Cash {
294-
closest(comparator: Comparator): Cash;
295+
closest(comparator?: Comparator): Cash;
295296
}
296297
interface Cash {
297298
parents(comparator?: Comparator): Cash;

0 commit comments

Comments
 (0)