Skip to content

Commit ac1a5d2

Browse files
Squeezed some more bytes out of the bundle (~1.5%), bringing back the minified and gzipped size below 5kb
1 parent a58e579 commit ac1a5d2

14 files changed

Lines changed: 26 additions & 34 deletions

File tree

src/collection/slice.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ interface Cash {
66
slice ( start?: number, end?: number ): Cash;
77
}
88

9-
fn.slice = function ( this: Cash ) {
9+
fn.slice = function ( this: Cash, start?: number, end?: number ) {
1010

11-
return cash ( slice.apply ( this, arguments ) );
11+
return cash ( slice.call ( this, start, end ) );
1212

1313
};

src/core/cash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ fn.length = 0;
5959
fn.splice = splice; // Ensuring a cash collection gets printed as array-like in Chrome's devtools
6060

6161
if ( typeof Symbol === 'function' ) { // Ensuring a cash collection is iterable
62-
fn[Symbol['iterator']] = Array.prototype[Symbol['iterator']];
62+
fn[Symbol['iterator']] = ArrayProtoType[Symbol['iterator']];
6363
}

src/core/each.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function each<T> ( arr: ArrayLike<T>, callback: EachCallback<T>, reverse?: boole
1515

1616
while ( i-- ) {
1717

18-
if ( callback.call ( arr[i], i, arr[i] ) === false ) break;
18+
if ( callback.call ( arr[i], i, arr[i] ) === false ) return arr;
1919

2020
}
2121

2222
} else {
2323

2424
for ( let i = 0, l = arr.length; i < l; i++ ) {
2525

26-
if ( callback.call ( arr[i], i, arr[i] ) === false ) break;
26+
if ( callback.call ( arr[i], i, arr[i] ) === false ) return arr;
2727

2828
}
2929

src/core/matches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface CashStatic {
77

88
function matches ( ele: any, selector: string ): boolean {
99

10-
const matches = ele && ( ele['matches'] || ele['webkitMatchesSelector'] || ele['mozMatchesSelector'] || ele['msMatchesSelector'] || ele['oMatchesSelector'] );
10+
const matches = ele && ( ele['matches'] || ele['webkitMatchesSelector'] || ele['msMatchesSelector'] );
1111

1212
return !!matches && matches.call ( ele, selector );
1313

src/core/pluck.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ function pluck<T> ( arr: ArrayLike<T>, prop: string | PluckCallback<T>, deep?: b
2727

2828
plucked.push ( val );
2929

30-
if ( !deep ) break;
31-
32-
val = val[prop];
30+
val = deep ? val[prop] : null;
3331

3432
}
3533

src/core/variables.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const doc = document,
77
table = createElement ( 'table' ),
88
tbody = createElement ( 'tbody' ),
99
tr = createElement ( 'tr' ),
10-
{isArray} = Array,
11-
{filter, indexOf, map, push, slice, some, splice} = Array.prototype;
10+
{isArray, prototype: ArrayProtoType} = Array,
11+
{filter, indexOf, map, push, slice, some, splice} = ArrayProtoType;
1212

1313
const idRe = /^#[\w-]*$/,
1414
classRe = /^\.[\w-]*$/,

src/css/helpers/get_prefixed_prop.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface CashStatic {
1111

1212
const prefixedProps: { [prop: string]: string } = {},
1313
{style} = div,
14-
vendorsPrefixes = ['webkit', 'moz', 'ms', 'o'];
14+
vendorsPrefixes = ['webkit', 'moz', 'ms'];
1515

1616
function getPrefixedProp ( prop: string, isVariable: boolean = isCSSVariable ( prop ) ): string {
1717

@@ -20,7 +20,7 @@ function getPrefixedProp ( prop: string, isVariable: boolean = isCSSVariable ( p
2020
if ( !prefixedProps[prop] ) {
2121

2222
const propCC = camelCase ( prop ),
23-
propUC = `${propCC.charAt ( 0 ).toUpperCase ()}${propCC.slice ( 1 )}`,
23+
propUC = `${propCC[0].toUpperCase ()}${propCC.slice ( 1 )}`,
2424
props = ( `${propCC} ${vendorsPrefixes.join ( `${propUC} ` )}${propUC}` ).split ( ' ' );
2525

2626
each ( props, ( i, p ) => {

src/data/data.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// @require collection/each.ts
55
// @require ./helpers/get_data.ts
66
// @require ./helpers/set_data.ts
7-
// @require ./helpers/variables.ts
87

98
interface Cash {
109
data (): plainObject | undefined;
@@ -25,17 +24,11 @@ function data ( this: Cash, name?: string | plainObject, value?: any ) {
2524

2625
const datas: { [data: string]: any } = {};
2726

28-
each ( this[0].attributes, ( i, attr ) => {
27+
for ( const key in this[0].dataset ) {
2928

30-
const match = attr.name.match ( dataAttributeRe );
29+
datas[key] = getData ( this[0], key );
3130

32-
if ( match ) {
33-
34-
datas[match[1]] = this.data ( match[1] );
35-
36-
}
37-
38-
});
31+
}
3932

4033
return datas;
4134

src/data/helpers/variables.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/effects/helpers/get_default_display.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function getDefaultDisplay ( tagName: string ): string {
99

1010
const ele = createElement ( tagName );
1111

12-
doc.body.appendChild ( ele );
12+
doc.body.insertBefore ( ele, null );
1313

1414
const display = computeStyle ( ele, 'display' );
1515

0 commit comments

Comments
 (0)