Skip to content

Commit

Permalink
split ES5 shim/sham tests into separate tests
Browse files Browse the repository at this point in the history
boolean results also now consistent with other tests
  • Loading branch information
jokeyrhyme committed May 6, 2013
1 parent 0d74ccc commit 25d892f
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 64 deletions.
39 changes: 39 additions & 0 deletions feature-detects/es5/es5array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*!
{
"name": "ES5 Array",
"property": "es5array",
"notes": [{
"name": "ES5 Shim documentation",
"href": "https://github.com/kriskowal/es5-shim"
}, {
"name": "ECMAScript 5.1 Language Specification",
"href": "http://www.ecma-international.org/ecma-262/5.1/"
}],
"async": false,
"authors": ["Ron Waldon (@jokeyrhyme)"],
"knownBugs": [],
"tags": []
}
!*/
/* DOC
Check if browser implements ECMAScript 5 Array per specification.
*/
define(['Modernizr'], function (Modernizr) {
// es5array
// test by @jokeyrhyme
Modernizr.addTest('es5array', function () {
return Array.prototype &&
Array.prototype.every &&
Array.prototype.filter &&
Array.prototype.forEach &&
Array.prototype.indexOf &&
Array.prototype.lastIndexOf &&
Array.prototype.map &&
Array.prototype.some &&
Array.prototype.reduce &&
Array.prototype.reduceRight &&
Array.isArray;
});
});
40 changes: 40 additions & 0 deletions feature-detects/es5/es5date.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*!
{
"name": "ES5 Date",
"property": "es5date",
"notes": [{
"name": "ES5 Shim documentation",
"href": "https://github.com/kriskowal/es5-shim"
}, {
"name": "ECMAScript 5.1 Language Specification",
"href": "http://www.ecma-international.org/ecma-262/5.1/"
}],
"async": false,
"authors": ["Ron Waldon (@jokeyrhyme)"],
"knownBugs": [],
"tags": []
}
!*/
/* DOC
Check if browser implements ECMAScript 5 Date per specification.
*/
define(['Modernizr'], function (Modernizr) {
// es5date
// test by @jokeyrhyme
Modernizr.addTest('es5date', function () {
var isoDate = '2013-04-12T06:06:37.307Z',
canParseISODate = false;
try {
canParseISODate = !!Date.parse(isoDate);
} catch (e) {
// no ISO date parsing yet
}
return Date.now &&
Date.prototype &&
Date.prototype.toISOString &&
Date.prototype.toJSON &&
canParseISODate;
});
});
29 changes: 29 additions & 0 deletions feature-detects/es5/es5function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*!
{
"name": "ES5 Function",
"property": "es5function",
"notes": [{
"name": "ES5 Shim documentation",
"href": "https://github.com/kriskowal/es5-shim"
}, {
"name": "ECMAScript 5.1 Language Specification",
"href": "http://www.ecma-international.org/ecma-262/5.1/"
}],
"async": false,
"authors": ["Ron Waldon (@jokeyrhyme)"],
"knownBugs": [],
"tags": []
}
!*/
/* DOC
Check if browser implements ECMAScript 5 Function per specification.
*/
define(['Modernizr'], function (Modernizr) {
// es5function
// test by @jokeyrhyme
Modernizr.addTest('es5function', function () {
return Function.prototype && Function.prototype.bind;
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*!
{
"name": "ES5 Sham",
"property": "es5sham",
"name": "ES5 Object",
"property": "es5object",
"notes": [{
"name": "ES5 Shim documentation",
"href": "https://github.com/kriskowal/es5-shim"
Expand All @@ -17,14 +17,15 @@
!*/
/* DOC
Check if browser needs ES5 Sham (true) or if it already implements ES5 (false).
Check if browser implements ECMAScript 5 Object per specification.
*/
define(['Modernizr'], function(Modernizr) {
// es5sham
define(['Modernizr'], function (Modernizr) {
// es5object
// test by @jokeyrhyme
Modernizr.addTest('es5sham', function() {
return !(Object.create &&
Modernizr.addTest('es5object', function () {
return Object.keys &&
Object.create &&
Object.getPrototypeOf &&
Object.getOwnPropertyNames &&
Object.isSealed &&
Expand All @@ -35,6 +36,6 @@ define(['Modernizr'], function(Modernizr) {
Object.defineProperties &&
Object.seal &&
Object.freeze &&
Object.preventExtensions);
Object.preventExtensions;
});
});
56 changes: 0 additions & 56 deletions feature-detects/es5/es5shim.js

This file was deleted.

29 changes: 29 additions & 0 deletions feature-detects/es5/es5string.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*!
{
"name": "ES5 String",
"property": "es5string",
"notes": [{
"name": "ES5 Shim documentation",
"href": "https://github.com/kriskowal/es5-shim"
}, {
"name": "ECMAScript 5.1 Language Specification",
"href": "http://www.ecma-international.org/ecma-262/5.1/"
}],
"async": false,
"authors": ["Ron Waldon (@jokeyrhyme)"],
"knownBugs": [],
"tags": []
}
!*/
/* DOC
Check if browser implements ECMAScript 5 String per specification.
*/
define(['Modernizr'], function (Modernizr) {
// es5string
// test by @jokeyrhyme
Modernizr.addTest('es5string', function () {
return String.prototype && String.prototype.trim;
});
});

0 comments on commit 25d892f

Please sign in to comment.