Skip to content
This repository was archived by the owner on Aug 21, 2022. It is now read-only.

Commit 439376f

Browse files
committed
build 0.6.0
1 parent c1ca9d6 commit 439376f

12 files changed

+297
-79
lines changed

dev/jscore-ie10.js

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jsCore JavaScript library v0.5.1 IE10+
1+
/* jsCore JavaScript library v0.6.0 IE10+
22
* © 2014 Dmitry Korobkin
33
* Released under the MIT license
44
* github.com/Octane/jsCore
@@ -135,6 +135,36 @@ if (!Array.prototype.fill) {
135135
};
136136
}
137137

138+
if (!Array.prototype.contains) {
139+
Array.prototype.contains = function (anything, position) {
140+
var length = this.length,
141+
i;
142+
if (!length) {
143+
return false;
144+
}
145+
if (Number.isNaN(anything)) {
146+
if (1 in arguments) {
147+
position = Number(position) || 0;
148+
if (position < 0) {
149+
i = Math.max(length + position, 0);
150+
} else {
151+
i = position;
152+
}
153+
} else {
154+
i = 0;
155+
}
156+
while (i < length) {
157+
if (i in this && Number.isNaN(this[i])) {
158+
return true;
159+
}
160+
i++;
161+
}
162+
return false;
163+
}
164+
return -1 != this.indexOf(anything, position);
165+
};
166+
}
167+
138168
if (!String.prototype.startsWith) {
139169
String.prototype.startsWith = function (string, position) {
140170
if (!position) {
@@ -255,7 +285,7 @@ new function () {
255285
'findIndex', 'forEach', 'indexOf', 'join',
256286
'lastIndexOf', 'map', 'pop', 'push', 'reduce',
257287
'reduceRight', 'reverse', 'shift', 'slice',
258-
'some', 'sort', 'splice', 'unshift'
288+
'some', 'sort', 'splice', 'unshift', 'contains'
259289
]));
260290

261291
implement(String, createGenerics(String.prototype, [
@@ -1101,7 +1131,7 @@ Object.defineProperty(HTMLElement.prototype, 'dataset', {
11011131
};
11021132

11031133
function isContains(root, element, selector) {
1104-
return -1 != Array.indexOf(root.querySelectorAll(selector), element);
1134+
return Array.contains(root.querySelectorAll(selector), element);
11051135
}
11061136

11071137
function mutationMacro(nodes) {
@@ -1169,10 +1199,6 @@ lib.array = {
11691199
}, 0);
11701200
},
11711201

1172-
contains: function (iterable, anything, position) {
1173-
return -1 != Array.indexOf(iterable, anything, position);
1174-
},
1175-
11761202
unique: function (iterable) {
11771203
var result = [],
11781204
anything,
@@ -1181,7 +1207,7 @@ lib.array = {
11811207
j = 0;
11821208
while (i < length) {
11831209
anything = iterable[i];
1184-
if (-1 == result.indexOf(anything)) {
1210+
if (!result.contains(anything)) {
11851211
result[j++] = anything;
11861212
}
11871213
i++;
@@ -1608,7 +1634,7 @@ lib.event = Object.assign({
16081634
return newNames;
16091635
}
16101636
return newNames.reduce(function (names, name) {
1611-
if (-1 == oldNames.indexOf(name)) {
1637+
if (!oldNames.contains(name)) {
16121638
names.push(name);
16131639
}
16141640
return names;

dev/jscore-ie9.js

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jsCore JavaScript library v0.5.1 IE9+
1+
/* jsCore JavaScript library v0.6.0 IE9+
22
* © 2014 Dmitry Korobkin
33
* Released under the MIT license
44
* github.com/Octane/jsCore
@@ -135,6 +135,36 @@ if (!Array.prototype.fill) {
135135
};
136136
}
137137

138+
if (!Array.prototype.contains) {
139+
Array.prototype.contains = function (anything, position) {
140+
var length = this.length,
141+
i;
142+
if (!length) {
143+
return false;
144+
}
145+
if (Number.isNaN(anything)) {
146+
if (1 in arguments) {
147+
position = Number(position) || 0;
148+
if (position < 0) {
149+
i = Math.max(length + position, 0);
150+
} else {
151+
i = position;
152+
}
153+
} else {
154+
i = 0;
155+
}
156+
while (i < length) {
157+
if (i in this && Number.isNaN(this[i])) {
158+
return true;
159+
}
160+
i++;
161+
}
162+
return false;
163+
}
164+
return -1 != this.indexOf(anything, position);
165+
};
166+
}
167+
138168
if (!String.prototype.startsWith) {
139169
String.prototype.startsWith = function (string, position) {
140170
if (!position) {
@@ -255,7 +285,7 @@ new function () {
255285
'findIndex', 'forEach', 'indexOf', 'join',
256286
'lastIndexOf', 'map', 'pop', 'push', 'reduce',
257287
'reduceRight', 'reverse', 'shift', 'slice',
258-
'some', 'sort', 'splice', 'unshift'
288+
'some', 'sort', 'splice', 'unshift', 'contains'
259289
]));
260290

261291
implement(String, createGenerics(String.prototype, [
@@ -1101,7 +1131,7 @@ Object.defineProperty(HTMLElement.prototype, 'dataset', {
11011131
};
11021132

11031133
function isContains(root, element, selector) {
1104-
return -1 != Array.indexOf(root.querySelectorAll(selector), element);
1134+
return Array.contains(root.querySelectorAll(selector), element);
11051135
}
11061136

11071137
function mutationMacro(nodes) {
@@ -1187,7 +1217,7 @@ Object.defineProperty(HTMLElement.prototype, 'classList', {
11871217
this._update();
11881218
length = this.length;
11891219
Array.forEach(arguments, function (token) {
1190-
if (-1 == Array.indexOf(this, token)) {
1220+
if (!Array.contains(this, token)) {
11911221
Array.push(this, token);
11921222
}
11931223
}, this);
@@ -1223,7 +1253,7 @@ Object.defineProperty(HTMLElement.prototype, 'classList', {
12231253

12241254
contains: function (token) {
12251255
this._update();
1226-
return -1 != Array.indexOf(this, token);
1256+
return Array.contains(this, token);
12271257
},
12281258

12291259
toString: function () {
@@ -1442,10 +1472,6 @@ lib.array = {
14421472
}, 0);
14431473
},
14441474

1445-
contains: function (iterable, anything, position) {
1446-
return -1 != Array.indexOf(iterable, anything, position);
1447-
},
1448-
14491475
unique: function (iterable) {
14501476
var result = [],
14511477
anything,
@@ -1454,7 +1480,7 @@ lib.array = {
14541480
j = 0;
14551481
while (i < length) {
14561482
anything = iterable[i];
1457-
if (-1 == result.indexOf(anything)) {
1483+
if (!result.contains(anything)) {
14581484
result[j++] = anything;
14591485
}
14601486
i++;
@@ -1881,7 +1907,7 @@ lib.event = Object.assign({
18811907
return newNames;
18821908
}
18831909
return newNames.reduce(function (names, name) {
1884-
if (-1 == oldNames.indexOf(name)) {
1910+
if (!oldNames.contains(name)) {
18851911
names.push(name);
18861912
}
18871913
return names;

dev/jscore-polyfill-ie10.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jsCore JavaScript polyfill v0.5.1 IE10+
1+
/* jsCore JavaScript polyfill v0.6.0 IE10+
22
* © 2014 Dmitry Korobkin
33
* Released under the MIT license
44
* github.com/Octane/jsCore
@@ -135,6 +135,36 @@ if (!Array.prototype.fill) {
135135
};
136136
}
137137

138+
if (!Array.prototype.contains) {
139+
Array.prototype.contains = function (anything, position) {
140+
var length = this.length,
141+
i;
142+
if (!length) {
143+
return false;
144+
}
145+
if (Number.isNaN(anything)) {
146+
if (1 in arguments) {
147+
position = Number(position) || 0;
148+
if (position < 0) {
149+
i = Math.max(length + position, 0);
150+
} else {
151+
i = position;
152+
}
153+
} else {
154+
i = 0;
155+
}
156+
while (i < length) {
157+
if (i in this && Number.isNaN(this[i])) {
158+
return true;
159+
}
160+
i++;
161+
}
162+
return false;
163+
}
164+
return -1 != this.indexOf(anything, position);
165+
};
166+
}
167+
138168
if (!String.prototype.startsWith) {
139169
String.prototype.startsWith = function (string, position) {
140170
if (!position) {
@@ -255,7 +285,7 @@ new function () {
255285
'findIndex', 'forEach', 'indexOf', 'join',
256286
'lastIndexOf', 'map', 'pop', 'push', 'reduce',
257287
'reduceRight', 'reverse', 'shift', 'slice',
258-
'some', 'sort', 'splice', 'unshift'
288+
'some', 'sort', 'splice', 'unshift', 'contains'
259289
]));
260290

261291
implement(String, createGenerics(String.prototype, [
@@ -1101,7 +1131,7 @@ Object.defineProperty(HTMLElement.prototype, 'dataset', {
11011131
};
11021132

11031133
function isContains(root, element, selector) {
1104-
return -1 != Array.indexOf(root.querySelectorAll(selector), element);
1134+
return Array.contains(root.querySelectorAll(selector), element);
11051135
}
11061136

11071137
function mutationMacro(nodes) {

dev/jscore-polyfill-ie9.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* jsCore JavaScript polyfill v0.5.1 IE9+
1+
/* jsCore JavaScript polyfill v0.6.0 IE9+
22
* © 2014 Dmitry Korobkin
33
* Released under the MIT license
44
* github.com/Octane/jsCore
@@ -135,6 +135,36 @@ if (!Array.prototype.fill) {
135135
};
136136
}
137137

138+
if (!Array.prototype.contains) {
139+
Array.prototype.contains = function (anything, position) {
140+
var length = this.length,
141+
i;
142+
if (!length) {
143+
return false;
144+
}
145+
if (Number.isNaN(anything)) {
146+
if (1 in arguments) {
147+
position = Number(position) || 0;
148+
if (position < 0) {
149+
i = Math.max(length + position, 0);
150+
} else {
151+
i = position;
152+
}
153+
} else {
154+
i = 0;
155+
}
156+
while (i < length) {
157+
if (i in this && Number.isNaN(this[i])) {
158+
return true;
159+
}
160+
i++;
161+
}
162+
return false;
163+
}
164+
return -1 != this.indexOf(anything, position);
165+
};
166+
}
167+
138168
if (!String.prototype.startsWith) {
139169
String.prototype.startsWith = function (string, position) {
140170
if (!position) {
@@ -255,7 +285,7 @@ new function () {
255285
'findIndex', 'forEach', 'indexOf', 'join',
256286
'lastIndexOf', 'map', 'pop', 'push', 'reduce',
257287
'reduceRight', 'reverse', 'shift', 'slice',
258-
'some', 'sort', 'splice', 'unshift'
288+
'some', 'sort', 'splice', 'unshift', 'contains'
259289
]));
260290

261291
implement(String, createGenerics(String.prototype, [
@@ -1101,7 +1131,7 @@ Object.defineProperty(HTMLElement.prototype, 'dataset', {
11011131
};
11021132

11031133
function isContains(root, element, selector) {
1104-
return -1 != Array.indexOf(root.querySelectorAll(selector), element);
1134+
return Array.contains(root.querySelectorAll(selector), element);
11051135
}
11061136

11071137
function mutationMacro(nodes) {
@@ -1187,7 +1217,7 @@ Object.defineProperty(HTMLElement.prototype, 'classList', {
11871217
this._update();
11881218
length = this.length;
11891219
Array.forEach(arguments, function (token) {
1190-
if (-1 == Array.indexOf(this, token)) {
1220+
if (!Array.contains(this, token)) {
11911221
Array.push(this, token);
11921222
}
11931223
}, this);
@@ -1223,7 +1253,7 @@ Object.defineProperty(HTMLElement.prototype, 'classList', {
12231253

12241254
contains: function (token) {
12251255
this._update();
1226-
return -1 != Array.indexOf(this, token);
1256+
return Array.contains(this, token);
12271257
},
12281258

12291259
toString: function () {

0 commit comments

Comments
 (0)