ie-compat 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/ie-compat/array_every.js +63 -0
- data/assets/ie-compat/array_filter.js +75 -0
- data/assets/ie-compat/array_indexof.js +74 -0
- data/assets/ie-compat/array_lastindexof.js +66 -0
- data/assets/ie-compat/array_map.js +67 -0
- data/assets/ie-compat/array_reduce.js +97 -0
- data/assets/ie-compat/array_reduceright.js +94 -0
- data/assets/ie-compat/array_some.js +63 -0
- data/lib/assets/ie-compat/9.js +11 -0
- data/{assets → lib/assets}/ie-compat/array_foreach.js +0 -0
- data/{assets → lib/assets}/ie-compat/console.js +0 -0
- data/{assets → lib/assets}/ie-compat/function_bind.js +0 -0
- data/{assets → lib/assets}/ie-compat/lt-9.js +0 -0
- data/{assets → lib/assets}/ie-compat/vendor/html5shiv-printshiv.js +0 -0
- data/{assets → lib/assets}/ie-compat/vendor/html5shiv.js +0 -0
- data/{assets → lib/assets}/ie-compat/vendor/json2.js +0 -0
- data/{assets → lib/assets}/ie-compat/vendor/selectivizr-min.js +0 -0
- data/lib/ie/compat.rb +1 -1
- data/lib/ie/compat/{railtie.rb → engine.rb} +1 -1
- data/lib/ie/compat/version.rb +1 -1
- metadata +20 -12
- data/assets/ie-compat/9.js +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c590aad440dd95ee526a2df9328810c8a4f289b4
|
4
|
+
data.tar.gz: 83adebe068eba3126fcf1abed667f02085ea868a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1f25390b2c4cc080dfc2e8a96135dd8c8a84bdb6cd088f8b39d682dc0faa696d21fa3bb7fab88505c468ef13006bcb17180bf92a6ebbb3fa0969f5085d6e0d1
|
7
|
+
data.tar.gz: 811fb00553e1516791499255137fdf51555de67dce17b8ccec27d6c14e99cd56c403c2c1e039aafaa4ce83083bc4d9b99c11e54c9f1306f7b1cd7b6de82c8ea1
|
@@ -0,0 +1,63 @@
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.16
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.16
|
4
|
+
if (!Array.prototype.every) {
|
5
|
+
|
6
|
+
Array.prototype.every = function every(callback, thisArg) {
|
7
|
+
'use strict';
|
8
|
+
var T, k;
|
9
|
+
|
10
|
+
if (this == null) {
|
11
|
+
throw new TypeError("this is null or not defined");
|
12
|
+
}
|
13
|
+
|
14
|
+
var kValue,
|
15
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
16
|
+
O = Object(this),
|
17
|
+
|
18
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
19
|
+
// 3. Let len be ToUint32(lenValue).
|
20
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
21
|
+
|
22
|
+
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
23
|
+
// See: http://es5.github.com/#x9.11
|
24
|
+
if ({}.toString.call(callback) !== "[object Function]") {
|
25
|
+
throw new TypeError(callback + " is not a function");
|
26
|
+
}
|
27
|
+
|
28
|
+
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
29
|
+
if (arguments.length >= 2) {
|
30
|
+
T = thisArg;
|
31
|
+
}
|
32
|
+
|
33
|
+
// 6. Let k be 0
|
34
|
+
k = 0;
|
35
|
+
|
36
|
+
// 7. Repeat, while k < len
|
37
|
+
while (k < len) {
|
38
|
+
|
39
|
+
// a. Let Pk be ToString(k).
|
40
|
+
// This is implicit for LHS operands of the in operator
|
41
|
+
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
42
|
+
// This step can be combined with c
|
43
|
+
// c. If kPresent is true, then
|
44
|
+
if (k in O) {
|
45
|
+
|
46
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
47
|
+
kValue = O[k];
|
48
|
+
|
49
|
+
// ii. Let testResult be the result of calling the [[Call]] internal method of callbackfn
|
50
|
+
// with T as the this value and argument list containing kValue, k, and O.
|
51
|
+
// iii. If ToBoolean(testResult) is false, return false.
|
52
|
+
// the steps above can be rewritten as
|
53
|
+
if(!!callback.call(T, kValue, k, O) === false)
|
54
|
+
return false;
|
55
|
+
|
56
|
+
}
|
57
|
+
// d. Increase k by 1
|
58
|
+
k++;
|
59
|
+
}
|
60
|
+
// 8. return true
|
61
|
+
return (true);
|
62
|
+
};
|
63
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.20
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.20
|
4
|
+
if (!Array.prototype.filter) {
|
5
|
+
|
6
|
+
Array.prototype.filter = function filter(callback, thisArg) {
|
7
|
+
'use strict';
|
8
|
+
var T, k, to;
|
9
|
+
|
10
|
+
if (this == null) {
|
11
|
+
throw new TypeError("this is null or not defined");
|
12
|
+
}
|
13
|
+
|
14
|
+
var kValue,
|
15
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
16
|
+
O = Object(this),
|
17
|
+
|
18
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
19
|
+
// 3. Let len be ToUint32(lenValue).
|
20
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
21
|
+
|
22
|
+
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
23
|
+
// See: http://es5.github.com/#x9.11
|
24
|
+
if ({}.toString.call(callback) !== "[object Function]") {
|
25
|
+
throw new TypeError(callback + " is not a function");
|
26
|
+
}
|
27
|
+
|
28
|
+
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
29
|
+
if (arguments.length >= 2) {
|
30
|
+
T = thisArg;
|
31
|
+
}
|
32
|
+
|
33
|
+
// 6. Let A be a new array created as if by the expression new Array( len)
|
34
|
+
var A = new Array();
|
35
|
+
|
36
|
+
// 7. Let k be 0
|
37
|
+
k = 0;
|
38
|
+
|
39
|
+
// 8. Let to be 0.
|
40
|
+
to = 0;
|
41
|
+
|
42
|
+
// 9. Repeat, while k < len
|
43
|
+
while (k < len) {
|
44
|
+
|
45
|
+
// a. Let Pk be ToString(k).
|
46
|
+
// This is implicit for LHS operands of the in operator
|
47
|
+
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
48
|
+
// This step can be combined with c
|
49
|
+
// c. If kPresent is true, then
|
50
|
+
if (k in O) {
|
51
|
+
|
52
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
53
|
+
kValue = O[k];
|
54
|
+
|
55
|
+
// ii. Let selected be the result of calling the [[Call]] internal method of callbackfn
|
56
|
+
// with T as the this value and argument list containing kValue, k, and O.
|
57
|
+
var selected = callback.call(T, kValue, k, O);
|
58
|
+
|
59
|
+
// iii. If ToBoolean(selected) is true, then
|
60
|
+
if(!!selected === true) {
|
61
|
+
// 1. Call the [[DefineOwnProperty]] internal method of A with arguments ToString(to), Property Descriptor
|
62
|
+
// {[[Value]]: kValue, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}, and false.
|
63
|
+
// not 100% compliant, but defineProperty is not available on IE < 9
|
64
|
+
A.push(kValue);
|
65
|
+
// 2. Increase to by 1
|
66
|
+
to++;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
// d. Increase k by 1
|
70
|
+
k++;
|
71
|
+
}
|
72
|
+
// 10. return A
|
73
|
+
return (A);
|
74
|
+
};
|
75
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.14
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.14
|
4
|
+
if (!Array.prototype.indexOf) {
|
5
|
+
|
6
|
+
Array.prototype.indexOf = function indexOf(searchElement, fromIndex) {
|
7
|
+
'use strict';
|
8
|
+
var T, k, n = 0;
|
9
|
+
|
10
|
+
if (this == null) {
|
11
|
+
throw new TypeError("this is null or not defined");
|
12
|
+
}
|
13
|
+
|
14
|
+
var kValue,
|
15
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
16
|
+
O = Object(this),
|
17
|
+
|
18
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
19
|
+
// 3. Let len be ToUint32(lenValue).
|
20
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
21
|
+
|
22
|
+
// 4. If len is 0, return -1.
|
23
|
+
if(len === 0)
|
24
|
+
return -1;
|
25
|
+
|
26
|
+
// 5. If argument fromIndex was passed let n be ToInteger(fromIndex); else let n be 0.
|
27
|
+
if (arguments.length >= 2) {
|
28
|
+
n = fromIndex | 0; // convert fromIndex to int.If it's NaN, the result is 0 (http://es5.github.io/#x9.4)
|
29
|
+
}
|
30
|
+
|
31
|
+
// 6. If n ≥ len, return -1.
|
32
|
+
if(n >= len) {
|
33
|
+
return -1;
|
34
|
+
}
|
35
|
+
|
36
|
+
// 7. If n ≥ 0, then
|
37
|
+
// a. Let k be n.
|
38
|
+
if(n >= 0) {
|
39
|
+
k = n;
|
40
|
+
} else {
|
41
|
+
// 8. Else, n<0
|
42
|
+
// a. Let k be len - abs(n).
|
43
|
+
k = len - (Math.abs(n));
|
44
|
+
// b. If k is less than 0, then let k be 0.
|
45
|
+
if(k < 0) {
|
46
|
+
k = 0
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
// 9. Repeat, while k < len
|
51
|
+
while (k < len) {
|
52
|
+
|
53
|
+
// a. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
54
|
+
// This step can be combined with b
|
55
|
+
// b. If kPresent is true, then
|
56
|
+
if (k in O) {
|
57
|
+
|
58
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
59
|
+
kValue = O[k];
|
60
|
+
|
61
|
+
// ii. Let same be the result of applying the Strict Equality Comparison Algorithm to searchElement and elementK.
|
62
|
+
// iii. If same is true, return k.
|
63
|
+
// combine the two steps together
|
64
|
+
if(searchElement === kValue) {
|
65
|
+
return k;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
// c. Increase k by 1
|
69
|
+
k++;
|
70
|
+
}
|
71
|
+
// 10. return -1
|
72
|
+
return (-1);
|
73
|
+
};
|
74
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.15
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.15
|
4
|
+
if (!Array.prototype.lastIndexOf) {
|
5
|
+
|
6
|
+
Array.prototype.lastIndexOf = function lastIndexOf(searchElement, fromIndex) {
|
7
|
+
'use strict';
|
8
|
+
var T, k, n ;
|
9
|
+
|
10
|
+
if (this == null) {
|
11
|
+
throw new TypeError("this is null or not defined");
|
12
|
+
}
|
13
|
+
|
14
|
+
var kValue,
|
15
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
16
|
+
O = Object(this),
|
17
|
+
|
18
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
19
|
+
// 3. Let len be ToUint32(lenValue).
|
20
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
21
|
+
|
22
|
+
// 4. If len is 0, return -1.
|
23
|
+
if(len === 0)
|
24
|
+
return -1;
|
25
|
+
|
26
|
+
// 5. If argument fromIndex was passed let n be ToInteger(fromIndex); else let n be len.
|
27
|
+
if (arguments.length >= 2) {
|
28
|
+
n = fromIndex | 0; // convert fromIndex to int.If it's NaN, the result is 0 (http://es5.github.io/#x9.4)
|
29
|
+
} else {
|
30
|
+
n = len;
|
31
|
+
}
|
32
|
+
|
33
|
+
// 6. If n ≥ 0, then let k be min(n, len – 1).
|
34
|
+
if(n >= 0) {
|
35
|
+
k = Math.min(n, len - 1);
|
36
|
+
} else {
|
37
|
+
// 7. Else, n<0
|
38
|
+
// a. Let k be len - abs(n).
|
39
|
+
k = len - (Math.abs(n));
|
40
|
+
}
|
41
|
+
|
42
|
+
// 8. Repeat, while k >= 0
|
43
|
+
while (k >= 0) {
|
44
|
+
|
45
|
+
// a. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
46
|
+
// This step can be combined with b
|
47
|
+
// b. If kPresent is true, then
|
48
|
+
if (k in O) {
|
49
|
+
|
50
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
51
|
+
kValue = O[k];
|
52
|
+
|
53
|
+
// ii. Let same be the result of applying the Strict Equality Comparison Algorithm to searchElement and elementK.
|
54
|
+
// iii. If same is true, return k.
|
55
|
+
// combine the two steps together
|
56
|
+
if(searchElement === kValue) {
|
57
|
+
return k;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
// c. Decrease k by 1
|
61
|
+
k--;
|
62
|
+
}
|
63
|
+
// 9. return -1
|
64
|
+
return (-1);
|
65
|
+
};
|
66
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.19
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.19
|
4
|
+
if (!Array.prototype.map) {
|
5
|
+
|
6
|
+
Array.prototype.map = function map(callback, thisArg) {
|
7
|
+
'use strict';
|
8
|
+
var T, k;
|
9
|
+
|
10
|
+
if (this == null) {
|
11
|
+
throw new TypeError("this is null or not defined");
|
12
|
+
}
|
13
|
+
|
14
|
+
var kValue,
|
15
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
16
|
+
O = Object(this),
|
17
|
+
|
18
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
19
|
+
// 3. Let len be ToUint32(lenValue).
|
20
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
21
|
+
|
22
|
+
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
23
|
+
// See: http://es5.github.com/#x9.11
|
24
|
+
if ({}.toString.call(callback) !== "[object Function]") {
|
25
|
+
throw new TypeError(callback + " is not a function");
|
26
|
+
}
|
27
|
+
|
28
|
+
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
29
|
+
if (arguments.length >= 2) {
|
30
|
+
T = thisArg;
|
31
|
+
}
|
32
|
+
|
33
|
+
// 6. Let A be a new array created as if by the expression new Array( len)
|
34
|
+
var A = new Array(len);
|
35
|
+
|
36
|
+
// 7. Let k be 0
|
37
|
+
k = 0;
|
38
|
+
|
39
|
+
// 8. Repeat, while k < len
|
40
|
+
while (k < len) {
|
41
|
+
|
42
|
+
// a. Let Pk be ToString(k).
|
43
|
+
// This is implicit for LHS operands of the in operator
|
44
|
+
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
45
|
+
// This step can be combined with c
|
46
|
+
// c. If kPresent is true, then
|
47
|
+
if (k in O) {
|
48
|
+
|
49
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
50
|
+
kValue = O[k];
|
51
|
+
|
52
|
+
// ii. Let mappedValue be the result of calling the [[Call]] internal method of callbackfn
|
53
|
+
// with T as the this value and argument list containing kValue, k, and O.
|
54
|
+
var mappedValue = callback.call(T, kValue, k, O);
|
55
|
+
|
56
|
+
// iii. Call the [[DefineOwnProperty]] internal method of A with arguments Pk, Property Descriptor
|
57
|
+
// {[[Value]]: mappedValue, [[Writable]]: true, [[Enumerable]]: true, [[Configurable]]: true}, and false.
|
58
|
+
// not 100% compliant implementation, but defineProperty is not supported in IE < 9
|
59
|
+
A[k] = mappedValue;
|
60
|
+
}
|
61
|
+
// d. Increase k by 1.
|
62
|
+
k++;
|
63
|
+
}
|
64
|
+
// 9. return A
|
65
|
+
return (A);
|
66
|
+
};
|
67
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.21
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.21
|
4
|
+
|
5
|
+
if (!Array.prototype.reduce) {
|
6
|
+
|
7
|
+
Array.prototype.reduce = function reduce(callback, initialValue) {
|
8
|
+
'use strict';
|
9
|
+
var T, k;
|
10
|
+
|
11
|
+
if (this == null) {
|
12
|
+
throw new TypeError("this is null or not defined");
|
13
|
+
}
|
14
|
+
|
15
|
+
var kValue,
|
16
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
17
|
+
O = Object(this),
|
18
|
+
|
19
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
20
|
+
// 3. Let len be ToUint32(lenValue).
|
21
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
22
|
+
|
23
|
+
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
24
|
+
// See: http://es5.github.com/#x9.11
|
25
|
+
if ({}.toString.call(callback) !== "[object Function]") {
|
26
|
+
throw new TypeError(callback + " is not a function");
|
27
|
+
}
|
28
|
+
|
29
|
+
// 5. If len is 0 and initialValue is not present, throw a TypeError exception.
|
30
|
+
if(len === 0 && arguments.length < 2) {
|
31
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
32
|
+
}
|
33
|
+
|
34
|
+
// 6. Let k be 0
|
35
|
+
k = 0;
|
36
|
+
|
37
|
+
var accumulator;
|
38
|
+
// 7. If initialValue is present, then
|
39
|
+
if(arguments.length > 1) {
|
40
|
+
// a. Set accumulator to initialValue.
|
41
|
+
accumulator = initialValue;
|
42
|
+
} else {
|
43
|
+
// NOTE: verbose but correct implementation
|
44
|
+
// 8. Else, initialValue is not present
|
45
|
+
// a. Let kPresent be false.
|
46
|
+
var kPresent = false;
|
47
|
+
|
48
|
+
// b. Repeat, while kPresent is false and k < len
|
49
|
+
while(kPresent === false && k < len) {
|
50
|
+
// i. Let Pk be ToString(k).
|
51
|
+
// This is implicit for LHS operands of the in operator
|
52
|
+
// ii. Let kPresent be the result of calling the [[HasProperty]] internal method of O with argument Pk.
|
53
|
+
kPresent = (k in O);
|
54
|
+
// iii. If kPresent is true, then
|
55
|
+
if(kPresent === true) {
|
56
|
+
// 1. Let accumulator be the result of calling the [[Get]] internal method of O with argument Pk.
|
57
|
+
accumulator = O[k];
|
58
|
+
}
|
59
|
+
|
60
|
+
// iv. Increase k by 1.
|
61
|
+
k++;
|
62
|
+
}
|
63
|
+
|
64
|
+
// c. If kPresent is false, throw a TypeError exception.
|
65
|
+
if(kPresent === false) {
|
66
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
// 7. Repeat, while k < len
|
72
|
+
while (k < len) {
|
73
|
+
|
74
|
+
// a. Let Pk be ToString(k).
|
75
|
+
// This is implicit for LHS operands of the in operator
|
76
|
+
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
77
|
+
// This step can be combined with c
|
78
|
+
// c. If kPresent is true, then
|
79
|
+
if (k in O) {
|
80
|
+
|
81
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
82
|
+
kValue = O[k];
|
83
|
+
|
84
|
+
// ii. Let accumulator be the result of calling the [[Call]] internal method of callbackfn
|
85
|
+
// with undefined as the this value and argument list containing accumulator, kValue, k, and O.
|
86
|
+
accumulator = callback.call(undefined, accumulator, kValue, k, O);
|
87
|
+
}
|
88
|
+
// d. Increase k by 1.
|
89
|
+
k++;
|
90
|
+
}
|
91
|
+
// 10. Return accumulator
|
92
|
+
return accumulator;
|
93
|
+
};
|
94
|
+
|
95
|
+
// default reduce behaviour is to reduce to the left
|
96
|
+
Array.prototype.reduceLeft = Array.prototype.reduce;
|
97
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRightRight#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.22
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.22
|
4
|
+
|
5
|
+
if (!Array.prototype.reduceRight) {
|
6
|
+
|
7
|
+
Array.prototype.reduceRight = function reduceRight(callback, initialValue) {
|
8
|
+
'use strict';
|
9
|
+
var T, k;
|
10
|
+
|
11
|
+
if (this == null) {
|
12
|
+
throw new TypeError("this is null or not defined");
|
13
|
+
}
|
14
|
+
|
15
|
+
var kValue,
|
16
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
17
|
+
O = Object(this),
|
18
|
+
|
19
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
20
|
+
// 3. Let len be ToUint32(lenValue).
|
21
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
22
|
+
|
23
|
+
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
24
|
+
// See: http://es5.github.com/#x9.11
|
25
|
+
if ({}.toString.call(callback) !== "[object Function]") {
|
26
|
+
throw new TypeError(callback + " is not a function");
|
27
|
+
}
|
28
|
+
|
29
|
+
// 5. If len is 0 and initialValue is not present, throw a TypeError exception.
|
30
|
+
if(len === 0 && arguments.length < 2) {
|
31
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
32
|
+
}
|
33
|
+
|
34
|
+
// 6. Let k be len-1
|
35
|
+
k = len-1;
|
36
|
+
|
37
|
+
var accumulator;
|
38
|
+
// 7. If initialValue is present, then
|
39
|
+
if(arguments.length > 1) {
|
40
|
+
// a. Set accumulator to initialValue.
|
41
|
+
accumulator = initialValue;
|
42
|
+
} else {
|
43
|
+
// NOTE: verbose but correct implementation
|
44
|
+
// 8. Else, initialValue is not present
|
45
|
+
// a. Let kPresent be false.
|
46
|
+
var kPresent = false;
|
47
|
+
|
48
|
+
// b. Repeat, while kPresent is false and k ≥ 0
|
49
|
+
while(kPresent === false && k >= 0) {
|
50
|
+
// i. Let Pk be ToString(k).
|
51
|
+
// This is implicit for LHS operands of the in operator
|
52
|
+
// ii. Let kPresent be the result of calling the [[HasProperty]] internal method of O with argument Pk.
|
53
|
+
kPresent = (k in O);
|
54
|
+
// iii. If kPresent is true, then
|
55
|
+
if(kPresent === true) {
|
56
|
+
// 1. Let accumulator be the result of calling the [[Get]] internal method of O with argument Pk.
|
57
|
+
accumulator = O[k];
|
58
|
+
}
|
59
|
+
|
60
|
+
// iv. Decrease k by 1.
|
61
|
+
k--;
|
62
|
+
}
|
63
|
+
|
64
|
+
// c. If kPresent is false, throw a TypeError exception.
|
65
|
+
if(kPresent === false) {
|
66
|
+
throw new TypeError("Reduce of empty array with no initial value");
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
// 7. Repeat, while k >= 0
|
72
|
+
while (k >= 0) {
|
73
|
+
|
74
|
+
// a. Let Pk be ToString(k).
|
75
|
+
// This is implicit for LHS operands of the in operator
|
76
|
+
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
77
|
+
// This step can be combined with c
|
78
|
+
// c. If kPresent is true, then
|
79
|
+
if (k in O) {
|
80
|
+
|
81
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
82
|
+
kValue = O[k];
|
83
|
+
|
84
|
+
// ii. Let accumulator be the result of calling the [[Call]] internal method of callbackfn
|
85
|
+
// with undefined as the this value and argument list containing accumulator, kValue, k, and O.
|
86
|
+
accumulator = callback.call(undefined, accumulator, kValue, k, O);
|
87
|
+
}
|
88
|
+
// d. Decrease k by 1.
|
89
|
+
k--;
|
90
|
+
}
|
91
|
+
// 10. Return accumulator
|
92
|
+
return accumulator;
|
93
|
+
};
|
94
|
+
}
|
@@ -0,0 +1,63 @@
|
|
1
|
+
// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some#Browser_compatibility
|
2
|
+
// Production steps of ECMA-262, Edition 5, 15.4.4.17
|
3
|
+
// Reference: http://es5.github.com/#x15.4.4.17
|
4
|
+
if (!Array.prototype.some) {
|
5
|
+
|
6
|
+
Array.prototype.some = function some(callback, thisArg) {
|
7
|
+
'use strict';
|
8
|
+
var T, k;
|
9
|
+
|
10
|
+
if (this == null) {
|
11
|
+
throw new TypeError("this is null or not defined");
|
12
|
+
}
|
13
|
+
|
14
|
+
var kValue,
|
15
|
+
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
|
16
|
+
O = Object(this),
|
17
|
+
|
18
|
+
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
|
19
|
+
// 3. Let len be ToUint32(lenValue).
|
20
|
+
len = O.length >>> 0; // Hack to convert O.length to a UInt32
|
21
|
+
|
22
|
+
// 4. If IsCallable(callback) is false, throw a TypeError exception.
|
23
|
+
// See: http://es5.github.com/#x9.11
|
24
|
+
if ({}.toString.call(callback) !== "[object Function]") {
|
25
|
+
throw new TypeError(callback + " is not a function");
|
26
|
+
}
|
27
|
+
|
28
|
+
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
|
29
|
+
if (arguments.length >= 2) {
|
30
|
+
T = thisArg;
|
31
|
+
}
|
32
|
+
|
33
|
+
// 6. Let k be 0
|
34
|
+
k = 0;
|
35
|
+
|
36
|
+
// 7. Repeat, while k < len
|
37
|
+
while (k < len) {
|
38
|
+
|
39
|
+
// a. Let Pk be ToString(k).
|
40
|
+
// This is implicit for LHS operands of the in operator
|
41
|
+
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
|
42
|
+
// This step can be combined with c
|
43
|
+
// c. If kPresent is true, then
|
44
|
+
if (k in O) {
|
45
|
+
|
46
|
+
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
|
47
|
+
kValue = O[k];
|
48
|
+
|
49
|
+
// ii. Let testResult be the result of calling the [[Call]] internal method of callbackfn
|
50
|
+
// with T as the this value and argument list containing kValue, k, and O.
|
51
|
+
// iii. If ToBoolean(testResult) is true, return true.
|
52
|
+
// the steps above can be rewritten as
|
53
|
+
if(!!callback.call(T, kValue, k, O) === true)
|
54
|
+
return true;
|
55
|
+
|
56
|
+
}
|
57
|
+
// d. Increase k by 1
|
58
|
+
k++;
|
59
|
+
}
|
60
|
+
// 8. return false
|
61
|
+
return (false);
|
62
|
+
};
|
63
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
//= require ie-compat/console
|
2
|
+
//= require ie-compat/function_bind
|
3
|
+
//= require ie-compat/array_every
|
4
|
+
//= require ie-compat/array_filter
|
5
|
+
//= require ie-compat/array_foreach
|
6
|
+
//= require ie-compat/array_indexof
|
7
|
+
//= require ie-compat/array_lastindexof
|
8
|
+
//= require ie-compat/array_map
|
9
|
+
//= require ie-compat/array_reduce
|
10
|
+
//= require ie-compat/array_reduceright
|
11
|
+
//= require ie-compat/array_some
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/ie/compat.rb
CHANGED
data/lib/ie/compat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ie-compat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -51,21 +51,29 @@ files:
|
|
51
51
|
- LICENSE.txt
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
|
-
- assets/ie-compat/
|
55
|
-
- assets/ie-compat/
|
56
|
-
- assets/ie-compat/
|
57
|
-
- assets/ie-compat/
|
58
|
-
- assets/ie-compat/
|
59
|
-
- assets/ie-compat/
|
60
|
-
- assets/ie-compat/
|
61
|
-
- assets/ie-compat/
|
62
|
-
- assets/ie-compat/vendor/selectivizr-min.js
|
54
|
+
- assets/ie-compat/array_every.js
|
55
|
+
- assets/ie-compat/array_filter.js
|
56
|
+
- assets/ie-compat/array_indexof.js
|
57
|
+
- assets/ie-compat/array_lastindexof.js
|
58
|
+
- assets/ie-compat/array_map.js
|
59
|
+
- assets/ie-compat/array_reduce.js
|
60
|
+
- assets/ie-compat/array_reduceright.js
|
61
|
+
- assets/ie-compat/array_some.js
|
63
62
|
- ie-compat.gemspec
|
63
|
+
- lib/assets/ie-compat/9.js
|
64
|
+
- lib/assets/ie-compat/array_foreach.js
|
65
|
+
- lib/assets/ie-compat/console.js
|
66
|
+
- lib/assets/ie-compat/function_bind.js
|
67
|
+
- lib/assets/ie-compat/lt-9.js
|
68
|
+
- lib/assets/ie-compat/vendor/html5shiv-printshiv.js
|
69
|
+
- lib/assets/ie-compat/vendor/html5shiv.js
|
70
|
+
- lib/assets/ie-compat/vendor/json2.js
|
71
|
+
- lib/assets/ie-compat/vendor/selectivizr-min.js
|
64
72
|
- lib/ie/compat.rb
|
65
73
|
- lib/ie/compat/active_admin.rb
|
66
74
|
- lib/ie/compat/assets_path.rb
|
75
|
+
- lib/ie/compat/engine.rb
|
67
76
|
- lib/ie/compat/opal.rb
|
68
|
-
- lib/ie/compat/railtie.rb
|
69
77
|
- lib/ie/compat/sprockets.rb
|
70
78
|
- lib/ie/compat/version.rb
|
71
79
|
- lib/ie/compat/view_helper.rb
|
data/assets/ie-compat/9.js
DELETED