[Pkg-javascript-commits] [node-es5-shim] 01/12: New upstream version 4.5.10
Julien Puydt
julien.puydt at laposte.net
Sun Dec 17 12:02:36 UTC 2017
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-es5-shim.
commit 125f1b3941b15fe3981fc9e7839685627837de90
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Sun Dec 17 12:29:43 2017 +0100
New upstream version 4.5.10
---
.eslintrc | 15 ++-
.gitignore | 6 ++
.npmrc | 1 +
.travis.yml | 179 +++++++++++++++++++++++--------
CHANGES | 13 +++
README.md | 2 +-
es5-sham.js | 27 +++--
es5-sham.map | 2 +-
es5-sham.min.js | 2 +-
es5-shim.js | 283 +++++++++++++++++++++++++++----------------------
es5-shim.map | 2 +-
es5-shim.min.js | 4 +-
package.json | 29 ++---
tests/.eslintrc | 4 +-
tests/spec/s-array.js | 8 ++
tests/spec/s-date.js | 12 +--
tests/spec/s-global.js | 14 ++-
tests/spec/s-object.js | 17 ++-
18 files changed, 395 insertions(+), 225 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index d45be18..43fa24e 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -4,12 +4,24 @@
"extends": "@ljharb",
"rules": {
+ "array-bracket-newline": 0,
+ "array-element-newline": 0,
+ "object-curly-newline": 0,
"camelcase": [0],
"complexity": [0, 10],
"dot-notation": [2, { "allowKeywords": false }],
"eqeqeq": [2, "allow-null"],
+ "func-name-matching": 0,
"id-length": [2, { "min": 1, "max": 40 }],
"indent": [2, 4],
+ "max-len": [2, 120, 4, {
+ "ignoreUrls": true,
+ "ignoreComments": true,
+ "ignoreRegExpLiterals": true,
+ "ignoreStrings": true,
+ "ignoreTemplateLiterals": true
+ }],
+ "max-lines": 0,
"max-nested-callbacks": [2, 5],
"max-params": [2, 7],
"max-statements": [1, 30],
@@ -32,8 +44,9 @@
"no-restricted-syntax": [2, "ContinueStatement", "DebuggerStatement", "LabeledStatement", "WithStatement"],
"no-shadow": [1],
"no-unused-vars": [1, { "vars": "all", "args": "after-used" }],
- "operator-linebreak": [2, "after"],
+ "operator-linebreak": [2, "before"],
"quote-props": [1, "as-needed", { "keywords": true }],
+ "sort-keys": [0],
"spaced-comment": [0],
"strict": [0]
}
diff --git a/.gitignore b/.gitignore
index fd4f2b0..02390fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,8 @@
+# gitignore
node_modules
.DS_Store
+
+# Only apps should have lockfiles
+npm-shrinkwrap.json
+package-lock.json
+yarn.lock
diff --git a/.npmrc b/.npmrc
new file mode 100644
index 0000000..43c97e7
--- /dev/null
+++ b/.npmrc
@@ -0,0 +1 @@
+package-lock=false
diff --git a/.travis.yml b/.travis.yml
index e9f887b..f4a86de 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,94 +1,185 @@
language: node_js
+os:
+ - linux
node_js:
- - "6.2"
- - "6.1"
- - "6.0"
- - "5.11"
- - "5.10"
- - "5.9"
- - "5.8"
- - "5.7"
- - "5.6"
- - "5.5"
- - "5.4"
- - "5.3"
- - "5.2"
- - "5.1"
- - "5.0"
- - "4.4"
- - "4.3"
- - "4.2"
- - "4.1"
- - "4.0"
+ - "9.3"
+ - "8.9"
+ - "7.10"
+ - "6.12"
+ - "5.12"
+ - "4.8"
- "iojs-v3.3"
- - "iojs-v3.2"
- - "iojs-v3.1"
- - "iojs-v3.0"
- "iojs-v2.5"
- - "iojs-v2.4"
- - "iojs-v2.3"
- - "iojs-v2.2"
- - "iojs-v2.1"
- - "iojs-v2.0"
- "iojs-v1.8"
- - "iojs-v1.7"
- - "iojs-v1.6"
- - "iojs-v1.5"
- - "iojs-v1.4"
- - "iojs-v1.3"
- - "iojs-v1.2"
- - "iojs-v1.1"
- - "iojs-v1.0"
- "0.12"
- - "0.11"
- "0.10"
- - "0.9"
- "0.8"
- - "0.6"
- - "0.4"
before_install:
- - 'if [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm at 1.4.28 ;; 2.*) npm install -g npm at 2 ;; esac ; fi'
- - 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then npm install -g npm; fi'
+ - 'nvm install-latest-npm'
+install:
+ - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
script:
- - 'if [ "${TRAVIS_NODE_VERSION}" != "4.4" ]; then npm run tests-only ; else npm test ; fi'
+ - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
+ - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi'
+ - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi'
+ - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
sudo: false
+env:
+ - TEST=true
matrix:
fast_finish: true
- allow_failures:
+ include:
+ - node_js: "lts/*"
+ env: PRETEST=true
+ - node_js: "9.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "9.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "9.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.11"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.10"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.2"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "6.1"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "6.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.11"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.10"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.9"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.8"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.7"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.6"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.5"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.4"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.3"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.2"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.1"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "5.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.4"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "4.3"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "4.2"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "4.1"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "4.0"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.2"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.1"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v3.0"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.4"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.3"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.2"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.1"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v2.0"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.7"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.6"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.5"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.4"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.3"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.2"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.1"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "iojs-v1.0"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "0.11"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "0.9"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "0.6"
+ env: TEST=true ALLOW_FAILURE=true
- node_js: "0.4"
+ env: TEST=true ALLOW_FAILURE=true
+ allow_failures:
+ - os: osx
+ - env: TEST=true ALLOW_FAILURE=true
+ - env: COVERAGE=true
diff --git a/CHANGES b/CHANGES
index 91f5d7a..85b69f9 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,16 @@
+4.5.10
+ - [Fix] Safari 11 throws on `.sort({})`, but not on `.sort(null)`
+ - [Fix] ensure the shimmed parseInt throws with Symbols (#450)
+ - [Fix] skip over `localStorage`, which can’t be accessed on file://
+ - [Fix] Accessing window.top.{constructor|prototype} throws error in iOS (#445)
+ - [Fix] avoid `width` and `height` on `window`, to prevent reflow (https://github.com/ljharb/object-keys/issues/31)
+ - [Fix] ensure minified literal of `1000000000000000128` stays as that literal (#441)
+ - [Robustness] always prefer `String(x)` over `x.toString()`
+ - [Tests] up to `node` `v9.3`, `v8.9`, `v7.10`, `v6.12`, `v5.12`, `v4.8`; improve test matrix; use `nvm install-latest-npm`; comment out OS X builds; pin included builds to LTS
+ - [Tests] `parseInt`: add another test for NaN parsing (#433)
+ - [Dev Deps] `uglify-js`: add `--support-ie8` and peg to v2.7.x since it doesn’t follow semver
+ - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`, `semver`; remove `concurrently` (#421)
+
4.5.9
- [Fix] parseInt and parseFloat should both accept null/undefined (#402)
- [Tests] up to `node` `v6.2`
diff --git a/README.md b/README.md
index 89c59bb..7f042e9 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-#es5-shim <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>
+# es5-shim <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>
[![npm badge][npm-badge-png]][npm-url]
diff --git a/es5-sham.js b/es5-sham.js
index 580cdde..ccdaa62 100644
--- a/es5-sham.js
+++ b/es5-sham.js
@@ -42,12 +42,12 @@
var lookupSetter;
var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
if (supportsAccessors) {
- /* eslint-disable no-underscore-dangle */
+ /* eslint-disable no-underscore-dangle, no-restricted-properties */
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
- /* eslint-enable no-underscore-dangle */
+ /* eslint-enable no-underscore-dangle, no-restricted-properties */
}
var isPrimitive = function isPrimitive(o) {
@@ -65,9 +65,8 @@
// ... this will nerever possibly return null
// ... Opera Mini breaks here with infinite loops
Object.getPrototypeOf = function getPrototypeOf(object) {
- /* eslint-disable no-proto */
+ // eslint-disable-next-line no-proto
var proto = object.__proto__;
- /* eslint-enable no-proto */
if (proto || proto === null) {
return proto;
} else if (toStr(object.constructor) === '[object Function]') {
@@ -99,8 +98,8 @@
// check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
if (Object.defineProperty) {
var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
- var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' ||
- doesGetOwnPropertyDescriptorWork(document.createElement('div'));
+ var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined'
+ || doesGetOwnPropertyDescriptorWork(document.createElement('div'));
if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
}
@@ -201,9 +200,9 @@
// Contributed by Brandon Benvie, October, 2012
var createEmpty;
var supportsProto = !({ __proto__: null } instanceof Object);
- // the following produces false positives
- // in Opera Mini => not a reliable check
- // Object.prototype.__proto__ === null
+ // the following produces false positives
+ // in Opera Mini => not a reliable check
+ // Object.prototype.__proto__ === null
// Check for document.domain and active x support
// No need to use active x approach when document.domain is not set
@@ -252,9 +251,8 @@
iframe.style.display = 'none';
parent.appendChild(iframe);
- /* eslint-disable no-script-url */
+ // eslint-disable-next-line no-script-url
iframe.src = 'javascript:';
- /* eslint-enable no-script-url */
empty = iframe.contentWindow.Object.prototype;
parent.removeChild(iframe);
@@ -319,9 +317,8 @@
// neither `__proto__`, but this manually setting `__proto__` will
// guarantee that `Object.getPrototypeOf` will work as expected with
// objects created using `Object.create`
- /* eslint-disable no-proto */
+ // eslint-disable-next-line no-proto
object.__proto__ = prototype;
- /* eslint-enable no-proto */
}
if (properties !== void 0) {
@@ -357,8 +354,8 @@
// shim partially.
if (Object.defineProperty) {
var definePropertyWorksOnObject = doesDefinePropertyWork({});
- var definePropertyWorksOnDom = typeof document === 'undefined' ||
- doesDefinePropertyWork(document.createElement('div'));
+ var definePropertyWorksOnDom = typeof document === 'undefined'
+ || doesDefinePropertyWork(document.createElement('div'));
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
var definePropertyFallback = Object.defineProperty,
definePropertiesFallback = Object.defineProperties;
diff --git a/es5-sham.map b/es5-sham.map
index cce47c1..5728951 100644
--- a/es5-sham.map
+++ b/es5-sham.map
@@ -1 +1 @@
-{"version":3,"sources":["es5-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","call","Function","prototypeOfObject","Object","prototype","owns","bind","hasOwnProperty","isEnumerable","propertyIsEnumerable","toStr","toString","defineGetter","defineSetter","lookupGetter","lookupSetter","supportsAccessors","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","isPrimitive","o","getPrototypeOf","object","proto","__proto__","co [...]
\ No newline at end of file
+{"version":3,"sources":["es5-sham.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","call","Function","prototypeOfObject","Object","prototype","owns","bind","hasOwnProperty","isEnumerable","propertyIsEnumerable","toStr","toString","defineGetter","defineSetter","lookupGetter","lookupSetter","supportsAccessors","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","isPrimitive","o","getPrototypeOf","object","proto","__proto__","co [...]
\ No newline at end of file
diff --git a/es5-sham.min.js b/es5-sham.min.js
index fd13f15..072b8f6 100644
--- a/es5-sham.min.js
+++ b/es5-sham.min.js
@@ -1,7 +1,7 @@
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
- * see https://github.com/es-shims/es5-shim/blob/v4.5.9/LICENSE
+ * see https://github.com/es-shims/es5-shim/blob/v4.5.10/LICENSE
*/
(function(e,t){"use strict";if(typeof define==="function"&&define.amd){define(t)}else if(typeof exports==="object"){module.exports=t()}else{e.returnExports=t()}})(this,function(){var e=Function.call;var t=Object.prototype;var r=e.bind(t.hasOwnProperty);var n=e.bind(t.propertyIsEnumerable);var o=e.bind(t.toString);var i;var c;var f;var a;var l=r(t,"__defineGetter__");if(l){i=e.bind(t.__defineGetter__);c=e.bind(t.__defineSetter__);f=e.bind(t.__lookupGetter__);a=e.bind(t.__lookupSetter__)}v [...]
//# sourceMappingURL=es5-sham.map
diff --git a/es5-shim.js b/es5-shim.js
index f94b433..f78a76f 100644
--- a/es5-shim.js
+++ b/es5-shim.js
@@ -340,6 +340,26 @@
var toStr = call.bind(ObjectPrototype.toString);
var arraySlice = call.bind(array_slice);
var arraySliceApply = apply.bind(array_slice);
+ /* globals document */
+ if (typeof document === 'object' && document && document.documentElement) {
+ try {
+ arraySlice(document.documentElement.childNodes);
+ } catch (e) {
+ var origArraySlice = arraySlice;
+ var origArraySliceApply = arraySliceApply;
+ arraySlice = function arraySliceIE(arr) {
+ var r = [];
+ var i = arr.length;
+ while (i-- > 0) {
+ r[i] = arr[i];
+ }
+ return origArraySliceApply(r, origArraySlice(arguments, 1));
+ };
+ arraySliceApply = function arraySliceApplyIE(arr, args) {
+ return origArraySliceApply(arraySlice(arr), args);
+ };
+ }
+ }
var strSlice = call.bind(StringPrototype.slice);
var strSplit = call.bind(StringPrototype.split);
var strIndexOf = call.bind(StringPrototype.indexOf);
@@ -933,10 +953,14 @@
var sortIgnoresNonFunctions = (function () {
try {
[1, 2].sort(null);
- [1, 2].sort({});
- return true;
- } catch (e) {}
- return false;
+ } catch (e) {
+ try {
+ [1, 2].sort({});
+ } catch (e2) {
+ return false;
+ }
+ }
+ return true;
}());
var sortThrowsOnRegex = (function () {
// this is a problem in Firefox 4, in which `typeof /a/ === 'function'`
@@ -975,14 +999,14 @@
// http://es5.github.com/#x15.2.3.14
// http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
- var hasDontEnumBug = !isEnum({ 'toString': null }, 'toString');
+ var hasDontEnumBug = !isEnum({ 'toString': null }, 'toString'); // jscs:ignore disallowQuotedKeysInObjects
var hasProtoEnumBug = isEnum(function () {}, 'prototype');
var hasStringEnumBug = !owns('x', '0');
var equalsConstructorPrototype = function (o) {
var ctor = o.constructor;
return ctor && ctor.prototype === o;
};
- var blacklistedKeys = {
+ var excludedKeys = {
$window: true,
$console: true,
$parent: true,
@@ -992,7 +1016,11 @@
$frameElement: true,
$webkitIndexedDB: true,
$webkitStorageInfo: true,
- $external: true
+ $external: true,
+ $width: true,
+ $height: true,
+ $top: true,
+ $localStorage: true
};
var hasAutomationEqualityBug = (function () {
/* globals window */
@@ -1001,7 +1029,7 @@
}
for (var k in window) {
try {
- if (!blacklistedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') {
+ if (!excludedKeys['$' + k] && owns(window, k) && window[k] !== null && typeof window[k] === 'object') {
equalsConstructorPrototype(window[k]);
}
} catch (e) {
@@ -1037,12 +1065,12 @@
return toStr(value) === '[object Arguments]';
};
var isLegacyArguments = function isArguments(value) {
- return value !== null &&
- typeof value === 'object' &&
- typeof value.length === 'number' &&
- value.length >= 0 &&
- !isArray(value) &&
- isCallable(value.callee);
+ return value !== null
+ && typeof value === 'object'
+ && typeof value.length === 'number'
+ && value.length >= 0
+ && !isArray(value)
+ && isCallable(value.callee);
};
var isArguments = isStandardArguments(arguments) ? isStandardArguments : isLegacyArguments;
@@ -1119,10 +1147,10 @@
var timeZoneOffset = aNegativeTestDate.getTimezoneOffset();
if (timeZoneOffset < -720) {
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Tue Jan 02 -45875';
- hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
+ hasToStringFormatBug = !(/^Thu Dec 10 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate));
} else {
hasToDateStringFormatBug = aNegativeTestDate.toDateString() !== 'Mon Jan 01 -45875';
- hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/).test(aPositiveTestDate.toString());
+ hasToStringFormatBug = !(/^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/).test(String(aPositiveTestDate));
}
var originalGetFullYear = call.bind(Date.prototype.getFullYear);
@@ -1231,13 +1259,13 @@
var hour = originalGetUTCHours(this);
var minute = originalGetUTCMinutes(this);
var second = originalGetUTCSeconds(this);
- return dayName[day] + ', ' +
- (date < 10 ? '0' + date : date) + ' ' +
- monthName[month] + ' ' +
- year + ' ' +
- (hour < 10 ? '0' + hour : hour) + ':' +
- (minute < 10 ? '0' + minute : minute) + ':' +
- (second < 10 ? '0' + second : second) + ' GMT';
+ return dayName[day] + ', '
+ + (date < 10 ? '0' + date : date) + ' '
+ + monthName[month] + ' '
+ + year + ' '
+ + (hour < 10 ? '0' + hour : hour) + ':'
+ + (minute < 10 ? '0' + minute : minute) + ':'
+ + (second < 10 ? '0' + second : second) + ' GMT';
}
}, hasNegativeMonthYearBug || hasToUTCStringFormatBug);
@@ -1251,10 +1279,10 @@
var date = this.getDate();
var month = this.getMonth();
var year = this.getFullYear();
- return dayName[day] + ' ' +
- monthName[month] + ' ' +
- (date < 10 ? '0' + date : date) + ' ' +
- year;
+ return dayName[day] + ' '
+ + monthName[month] + ' '
+ + (date < 10 ? '0' + date : date) + ' '
+ + year;
}
}, hasNegativeMonthYearBug || hasToDateStringFormatBug);
@@ -1274,16 +1302,16 @@
var timezoneOffset = this.getTimezoneOffset();
var hoursOffset = Math.floor(Math.abs(timezoneOffset) / 60);
var minutesOffset = Math.floor(Math.abs(timezoneOffset) % 60);
- return dayName[day] + ' ' +
- monthName[month] + ' ' +
- (date < 10 ? '0' + date : date) + ' ' +
- year + ' ' +
- (hour < 10 ? '0' + hour : hour) + ':' +
- (minute < 10 ? '0' + minute : minute) + ':' +
- (second < 10 ? '0' + second : second) + ' GMT' +
- (timezoneOffset > 0 ? '-' : '+') +
- (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset) +
- (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset);
+ return dayName[day] + ' '
+ + monthName[month] + ' '
+ + (date < 10 ? '0' + date : date) + ' '
+ + year + ' '
+ + (hour < 10 ? '0' + hour : hour) + ':'
+ + (minute < 10 ? '0' + minute : minute) + ':'
+ + (second < 10 ? '0' + second : second) + ' GMT'
+ + (timezoneOffset > 0 ? '-' : '+')
+ + (hoursOffset < 10 ? '0' + hoursOffset : hoursOffset)
+ + (minutesOffset < 10 ? '0' + minutesOffset : minutesOffset);
};
if (supportsDescriptors) {
$Object.defineProperty(Date.prototype, 'toString', {
@@ -1303,7 +1331,7 @@
// this object is not a finite Number a RangeError exception is thrown.
var negativeDate = -62198755200000;
var negativeYearString = '-000001';
- var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
+ var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1; // eslint-disable-line max-len
var hasSafari51DateBug = Date.prototype.toISOString && new Date(-1).toISOString() !== '1969-12-31T23:59:59.999Z';
var getTime = call.bind(Date.prototype.getTime);
@@ -1320,13 +1348,19 @@
var month = originalGetUTCMonth(this);
// see https://github.com/es-shims/es5-shim/issues/111
year += Math.floor(month / 12);
- month = (month % 12 + 12) % 12;
+ month = ((month % 12) + 12) % 12;
// the date time string format is specified in 15.9.1.15.
- var result = [month + 1, originalGetUTCDate(this), originalGetUTCHours(this), originalGetUTCMinutes(this), originalGetUTCSeconds(this)];
+ var result = [
+ month + 1,
+ originalGetUTCDate(this),
+ originalGetUTCHours(this),
+ originalGetUTCMinutes(this),
+ originalGetUTCSeconds(this)
+ ];
year = (
- (year < 0 ? '-' : (year > 9999 ? '+' : '')) +
- strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6)
+ (year < 0 ? '-' : (year > 9999 ? '+' : ''))
+ + strSlice('00000' + Math.abs(year), (0 <= year && year <= 9999) ? -4 : -6)
);
for (var i = 0; i < result.length; ++i) {
@@ -1335,9 +1369,9 @@
}
// pad milliseconds to have three digits.
return (
- year + '-' + arraySlice(result, 0, 2).join('-') +
- 'T' + arraySlice(result, 2).join(':') + '.' +
- strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z'
+ year + '-' + arraySlice(result, 0, 2).join('-')
+ + 'T' + arraySlice(result, 2).join(':') + '.'
+ + strSlice('000' + originalGetUTCMilliseconds(this), -3) + 'Z'
);
}
}, hasNegativeDateBug || hasSafari51DateBug);
@@ -1348,10 +1382,10 @@
// JSON.stringify (15.12.3).
var dateToJSONIsSupported = (function () {
try {
- return Date.prototype.toJSON &&
- new Date(NaN).toJSON() === null &&
- new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
- Date.prototype.toJSON.call({ // generic
+ return Date.prototype.toJSON
+ && new Date(NaN).toJSON() === null
+ && new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1
+ && Date.prototype.toJSON.call({ // generic
toISOString: function () { return true; }
});
} catch (e) {
@@ -1405,13 +1439,10 @@
// XXX global assignment won't work in embeddings that use
// an alternate object for the context.
/* global Date: true */
- /* eslint-disable no-undef */
var maxSafeUnsigned32Bit = Math.pow(2, 31) - 1;
var hasSafariSignedIntBug = isActualNaN(new Date(1970, 0, 1, 0, 0, 0, maxSafeUnsigned32Bit + 1).getTime());
- /* eslint-disable no-implicit-globals */
+ // eslint-disable-next-line no-implicit-globals, no-global-assign
Date = (function (NativeDate) {
- /* eslint-enable no-implicit-globals */
- /* eslint-enable no-undef */
// Date.length === 7
var DateShim = function Date(Y, M, D, h, m, s, ms) {
var length = arguments.length;
@@ -1426,19 +1457,19 @@
seconds += sToShift;
millis -= sToShift * 1e3;
}
- date = length === 1 && $String(Y) === Y ? // isString(Y)
+ date = length === 1 && $String(Y) === Y // isString(Y)
// We explicitly pass it through parse:
- new NativeDate(DateShim.parse(Y)) :
+ ? new NativeDate(DateShim.parse(Y))
// We have to manually make calls depending on argument
// length here
- length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis) :
- length >= 6 ? new NativeDate(Y, M, D, h, m, seconds) :
- length >= 5 ? new NativeDate(Y, M, D, h, m) :
- length >= 4 ? new NativeDate(Y, M, D, h) :
- length >= 3 ? new NativeDate(Y, M, D) :
- length >= 2 ? new NativeDate(Y, M) :
- length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) :
- new NativeDate();
+ : length >= 7 ? new NativeDate(Y, M, D, h, m, seconds, millis)
+ : length >= 6 ? new NativeDate(Y, M, D, h, m, seconds)
+ : length >= 5 ? new NativeDate(Y, M, D, h, m)
+ : length >= 4 ? new NativeDate(Y, M, D, h)
+ : length >= 3 ? new NativeDate(Y, M, D)
+ : length >= 2 ? new NativeDate(Y, M)
+ : length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y)
+ : new NativeDate();
} else {
date = NativeDate.apply(this, arguments);
}
@@ -1450,38 +1481,37 @@
};
// 15.9.1.15 Date Time String Format.
- var isoDateExpression = new RegExp('^' +
- '(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign +
- // 6-digit extended year
- '(?:-(\\d{2})' + // optional month capture
- '(?:-(\\d{2})' + // optional day capture
- '(?:' + // capture hours:minutes:seconds.milliseconds
- 'T(\\d{2})' + // hours capture
- ':(\\d{2})' + // minutes capture
- '(?:' + // optional :seconds.milliseconds
- ':(\\d{2})' + // seconds capture
- '(?:(\\.\\d{1,}))?' + // milliseconds capture
- ')?' +
- '(' + // capture UTC offset component
- 'Z|' + // UTC capture
- '(?:' + // offset specifier +/-hours:minutes
- '([-+])' + // sign capture
- '(\\d{2})' + // hours offset capture
- ':(\\d{2})' + // minutes offset capture
- ')' +
- ')?)?)?)?' +
- '$');
+ var isoDateExpression = new RegExp('^'
+ + '(\\d{4}|[+-]\\d{6})' // four-digit year capture or sign + 6-digit extended year
+ + '(?:-(\\d{2})' // optional month capture
+ + '(?:-(\\d{2})' // optional day capture
+ + '(?:' // capture hours:minutes:seconds.milliseconds
+ + 'T(\\d{2})' // hours capture
+ + ':(\\d{2})' // minutes capture
+ + '(?:' // optional :seconds.milliseconds
+ + ':(\\d{2})' // seconds capture
+ + '(?:(\\.\\d{1,}))?' // milliseconds capture
+ + ')?'
+ + '(' // capture UTC offset component
+ + 'Z|' // UTC capture
+ + '(?:' // offset specifier +/-hours:minutes
+ + '([-+])' // sign capture
+ + '(\\d{2})' // hours offset capture
+ + ':(\\d{2})' // minutes offset capture
+ + ')'
+ + ')?)?)?)?'
+ + '$');
var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
var dayFromMonth = function dayFromMonth(year, month) {
var t = month > 1 ? 1 : 0;
return (
- months[month] +
- Math.floor((year - 1969 + t) / 4) -
- Math.floor((year - 1901 + t) / 100) +
- Math.floor((year - 1601 + t) / 400) +
- 365 * (year - 1970)
+ months[month]
+ + Math.floor((year - 1969 + t) / 4)
+ - Math.floor((year - 1901 + t) / 100)
+ + Math.floor((year - 1601 + t) / 400)
+ + (365 * (year - 1970))
);
};
@@ -1511,9 +1541,7 @@
UTC: NativeDate.UTC
}, true);
DateShim.prototype = NativeDate.prototype;
- defineProperties(DateShim.prototype, {
- constructor: DateShim
- }, true);
+ defineProperties(DateShim.prototype, { constructor: DateShim }, true);
// Upgrade Date.parse to handle simplified ISO 8601 strings
var parseShim = function parse(string) {
@@ -1539,22 +1567,22 @@
result;
var hasMinutesOrSecondsOrMilliseconds = minute > 0 || second > 0 || millisecond > 0;
if (
- hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25) &&
- minute < 60 && second < 60 && millisecond < 1000 &&
- month > -1 && month < 12 && hourOffset < 24 &&
- minuteOffset < 60 && // detect invalid offsets
- day > -1 &&
- day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month))
+ hour < (hasMinutesOrSecondsOrMilliseconds ? 24 : 25)
+ && minute < 60 && second < 60 && millisecond < 1000
+ && month > -1 && month < 12 && hourOffset < 24
+ && minuteOffset < 60 // detect invalid offsets
+ && day > -1
+ && day < (dayFromMonth(year, month + 1) - dayFromMonth(year, month))
) {
result = (
- (dayFromMonth(year, month) + day) * 24 +
- hour +
- hourOffset * signOffset
+ ((dayFromMonth(year, month) + day) * 24)
+ + hour
+ + (hourOffset * signOffset)
) * 60;
- result = (
- (result + minute + minuteOffset * signOffset) * 60 +
- second
- ) * 1000 + millisecond;
+ result = ((
+ ((result + minute + (minuteOffset * signOffset)) * 60)
+ + second
+ ) * 1000) + millisecond;
if (isLocalTime) {
result = toUTC(result);
}
@@ -1589,10 +1617,10 @@
// ES5.1 15.7.4.5
// http://es5.github.com/#x15.7.4.5
var hasToFixedBugs = NumberPrototype.toFixed && (
- (0.00008).toFixed(3) !== '0.000' ||
- (0.9).toFixed(0) !== '1' ||
- (1.255).toFixed(2) !== '1.25' ||
- (1000000000000000128).toFixed(0) !== '1000000000000000128'
+ (0.00008).toFixed(3) !== '0.000'
+ || (0.9).toFixed(0) !== '1'
+ || (1.255).toFixed(2) !== '1.25'
+ || (1000000000000000128).toFixed(0) !== '1000000000000000128'
);
var toFixedHelpers = {
@@ -1770,12 +1798,12 @@
// '.'.split(/()()/) should be ["."], not ["", "", "."]
if (
- 'ab'.split(/(?:ab)*/).length !== 2 ||
- '.'.split(/(.?)(.?)/).length !== 4 ||
- 'tesst'.split(/(s)*/)[1] === 't' ||
- 'test'.split(/(?:)/, -1).length !== 4 ||
- ''.split(/.?/).length ||
- '.'.split(/()()/).length > 1
+ 'ab'.split(/(?:ab)*/).length !== 2
+ || '.'.split(/(.?)(.?)/).length !== 4
+ || 'tesst'.split(/(s)*/)[1] === 't'
+ || 'test'.split(/(?:)/, -1).length !== 4
+ || ''.split(/.?/).length
+ || '.'.split(/()()/).length > 1
) {
(function () {
var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group
@@ -1793,10 +1821,10 @@
}
var output = [];
- var flags = (separator.ignoreCase ? 'i' : '') +
- (separator.multiline ? 'm' : '') +
- (separator.unicode ? 'u' : '') + // in ES6
- (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6
+ var flags = (separator.ignoreCase ? 'i' : '')
+ + (separator.multiline ? 'm' : '')
+ + (separator.unicode ? 'u' : '') // in ES6
+ + (separator.sticky ? 'y' : ''), // Firefox 3+ and ES6
lastLastIndex = 0,
// Make `global` and avoid `lastIndex` issues by working with a copy
separator2, match, lastIndex, lastLength;
@@ -1921,9 +1949,9 @@
// ES5 15.5.4.20
// whitespace from: http://es5.github.io/#x15.5.4.20
- var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
- '\u2029\uFEFF';
+ var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003'
+ + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028'
+ + '\u2029\uFEFF';
var zeroWidth = '\u200b';
var wsRegexChars = '[' + ws + ']';
var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*');
@@ -1973,13 +2001,18 @@
}, StringPrototype.lastIndexOf.length !== 1);
// ES-5 15.1.2.2
- /* eslint-disable radix */
+ // eslint-disable-next-line radix
if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
- /* eslint-enable radix */
/* global parseInt: true */
parseInt = (function (origParseInt) {
- var hexRegex = /^[\-+]?0[xX]/;
+ var hexRegex = /^[-+]?0[xX]/;
return function parseInt(str, radix) {
+ if (typeof str === 'symbol') {
+ // handle Symbols in node 8.3/8.4
+ // eslint-disable-next-line no-implicit-coercion, no-unused-expressions
+ '' + str; // jscs:ignore disallowImplicitTypeConversion
+ }
+
var string = trim(String(str));
var defaultedRadix = $Number(radix) || (hexRegex.test(string) ? 16 : 10);
return origParseInt(string, defaultedRadix);
diff --git a/es5-shim.map b/es5-shim.map
index 5118831..5d5d10b 100644
--- a/es5-shim.map
+++ b/es5-shim.map
@@ -1 +1 @@
-{"version":3,"sources":["es5-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","$Array","Array","ArrayPrototype","prototype","$Object","Object","ObjectPrototype","$Function","Function","FunctionPrototype","$String","String","StringPrototype","$Number","Number","NumberPrototype","array_slice","slice","array_splice","splice","array_push","push","array_unshift","unshift","array_concat","concat","array_join","join","call","apply","max","Math","min", [...]
\ No newline at end of file
+{"version":3,"sources":["es5-shim.js"],"names":["root","factory","define","amd","exports","module","returnExports","this","$Array","Array","ArrayPrototype","prototype","$Object","Object","ObjectPrototype","$Function","Function","FunctionPrototype","$String","String","StringPrototype","$Number","Number","NumberPrototype","array_slice","slice","array_splice","splice","array_push","push","array_unshift","unshift","array_concat","concat","array_join","join","call","apply","max","Math","min", [...]
\ No newline at end of file
diff --git a/es5-shim.min.js b/es5-shim.min.js
index 14b24f1..9e96a3c 100644
--- a/es5-shim.min.js
+++ b/es5-shim.min.js
@@ -1,7 +1,7 @@
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
- * see https://github.com/es-shims/es5-shim/blob/v4.5.9/LICENSE
+ * see https://github.com/es-shims/es5-shim/blob/v4.5.10/LICENSE
*/
-(function(t,r){"use strict";if(typeof define==="function"&&define.amd){define(r)}else if(typeof exports==="object"){module.exports=r()}else{t.returnExports=r()}})(this,function(){var t=Array;var r=t.prototype;var e=Object;var n=e.prototype;var i=Function;var a=i.prototype;var o=String;var f=o.prototype;var u=Number;var l=u.prototype;var s=r.slice;var c=r.splice;var v=r.push;var h=r.unshift;var p=r.concat;var y=r.join;var d=a.call;var g=a.apply;var w=Math.max;var b=Math.min;var T=n.toStri [...]
+(function(t,r){"use strict";if(typeof define==="function"&&define.amd){define(r)}else if(typeof exports==="object"){module.exports=r()}else{t.returnExports=r()}})(this,function(){var t=Array;var r=t.prototype;var e=Object;var n=e.prototype;var i=Function;var a=i.prototype;var o=String;var f=o.prototype;var u=Number;var l=u.prototype;var s=r.slice;var c=r.splice;var v=r.push;var h=r.unshift;var p=r.concat;var y=r.join;var d=a.call;var g=a.apply;var w=Math.max;var b=Math.min;var T=n.toStri [...]
//# sourceMappingURL=es5-shim.map
diff --git a/package.json b/package.json
index 2c04981..38b1e7a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "es5-shim",
- "version": "4.5.9",
+ "version": "4.5.10",
"description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
"homepage": "http://github.com/es-shims/es5-shim/",
"contributors": [
@@ -22,26 +22,25 @@
"url": "http://github.com/es-shims/es5-shim.git"
},
"scripts": {
- "minify": "concurrently --raw 'npm run --silent minify-shim' 'npm run --silent minify-sham'",
- "minify-shim": "uglifyjs es5-shim.js --keep-fnames --comments --source-map=es5-shim.map -m -b ascii_only=true,beautify=false > es5-shim.min.js",
- "minify-sham": "uglifyjs es5-sham.js --keep-fnames --comments --source-map=es5-sham.map -m -b ascii_only=true,beautify=false > es5-sham.min.js",
+ "minify": "npm run --silent minify-shim && npm run --silent minify-sham",
+ "minify-shim": "uglifyjs es5-shim.js --support-ie8 --keep-fnames --comments --source-map=es5-shim.map -m -b ascii_only=true,beautify=false | sed 's/0xde0b6b3a7640080/1000000000000000128/' > es5-shim.min.js",
+ "minify-sham": "uglifyjs es5-sham.js --support-ie8 --keep-fnames --comments --source-map=es5-sham.map -m -b ascii_only=true,beautify=false > es5-sham.min.js",
"pretest": "npm run --silent lint",
"test": "npm run --silent tests-only",
"tests-only": "jasmine-node --matchall ./ tests/spec/",
"test-native": "jasmine-node --matchall tests/spec/",
- "lint": "concurrently --raw 'npm run --silent jscs' 'npm run --silent eslint'",
+ "lint": "npm run --silent jscs && npm run --silent eslint",
"eslint": "eslint tests/helpers/*.js tests/spec/*.js es5-shim.js es5-sham.js",
"jscs": "jscs tests/helpers/*.js tests/spec/*.js es5-shim.js es5-sham.js"
},
"devDependencies": {
- "eslint": "^2.12.0",
- "@ljharb/eslint-config": "^5.0.0",
+ "@ljharb/eslint-config": "^12.2.1",
+ "eslint": "^4.13.1",
"jasmine-node": "^1.14.5",
- "jscs": "^3.0.4",
- "uglify-js": "^2.6.2",
+ "jscs": "^3.0.7",
"replace": "^0.3.0",
- "semver": "^5.1.0",
- "concurrently": "^2.1.0"
+ "semver": "^5.4.1",
+ "uglify-js": "2.7.3"
},
"engines": {
"node": ">=0.4.0"
@@ -70,6 +69,10 @@
"javascript",
"ecmascript",
"polyfill"
- ]
+ ],
+ "greenkeeper": {
+ "ignore": [
+ "uglify-js"
+ ]
+ }
}
-
diff --git a/tests/.eslintrc b/tests/.eslintrc
index 168cdf8..ca0e2c8 100644
--- a/tests/.eslintrc
+++ b/tests/.eslintrc
@@ -1,5 +1,7 @@
{
"rules": {
- "max-statements-per-line": [2, { "max": 2 }]
+ "max-len": 0,
+ "max-lines": 0,
+ "max-statements-per-line": [2, { "max": 2 }],
}
}
diff --git a/tests/spec/s-array.js b/tests/spec/s-array.js
index c1bd0b6..75d3029 100644
--- a/tests/spec/s-array.js
+++ b/tests/spec/s-array.js
@@ -1599,6 +1599,14 @@ describe('Array', function () {
var result = Array.prototype.slice.call(obj, 1, 3);
expect(result).toEqual(['2', '3']);
});
+
+ /* globals document */
+ if (typeof document !== 'undefined') {
+ it('should be able to slice a NodeList', function () {
+ var nodes = document.getElementsByTagName('div');
+ expect(Array.isArray(Array.prototype.slice.call(nodes))).toBe(true);
+ });
+ }
});
describe('#sort()', function () {
diff --git a/tests/spec/s-date.js b/tests/spec/s-date.js
index 3f65fb2..397a5bb 100644
--- a/tests/spec/s-date.js
+++ b/tests/spec/s-date.js
@@ -132,8 +132,8 @@ describe('Date', function () {
expect(+new Date('2011-03-01T12:00:00.000Z')).toBe(1298980800000); // 1298980800000 1298980800000 1298980800000 1298980800000 1298980800000
// https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
- expect(new Date('2034-03-01T00:00:00.000Z') -
- new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
+ expect(new Date('2034-03-01T00:00:00.000Z')
+ - new Date('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
});
@@ -221,8 +221,8 @@ describe('Date', function () {
}
// https://github.com/es-shims/es5-shim/issues/80 Safari bug with leap day
- expect(Date.parse('2034-03-01T00:00:00.000Z') -
- Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
+ expect(Date.parse('2034-03-01T00:00:00.000Z')
+ - Date.parse('2034-02-27T23:59:59.999Z')).toBe(86400001); // 86400001 86400001 86400001 86400001 1
});
@@ -457,7 +457,7 @@ describe('Date', function () {
item.dates.forEach(function (date) {
var off = date.getTimezoneOffset();
var offHours = Math.floor(off / 60);
- var offMins = off - offHours * 60;
+ var offMins = off - (offHours * 60);
expect(date.getMinutes() + offMins).toBe(59);
});
});
@@ -521,7 +521,7 @@ describe('Date', function () {
describe('#toString()', function () {
it('should return correct dates', function () {
var actual = new Date(1449662400000).toString();
- var re = /^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-\+]\d\d\d\d(?: |$)/;
+ var re = /^Wed Dec 09 2015 \d\d:\d\d:\d\d GMT[-+]\d\d\d\d(?: |$)/;
expect(re.test(actual)).toBe(true, actual);
});
});
diff --git a/tests/spec/s-global.js b/tests/spec/s-global.js
index 9620681..b7bbc9b 100644
--- a/tests/spec/s-global.js
+++ b/tests/spec/s-global.js
@@ -6,6 +6,8 @@ describe('global methods', function () {
var foo = function foo() {};
var functionsHaveNames = foo.name === 'foo';
var ifFunctionsHaveNamesIt = functionsHaveNames ? it : xit;
+ var hasSymbols = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol';
+ var ifSymbolsIt = hasSymbols ? it : xit;
var is = function (x, y) {
if (x === 0 && y === 0) {
@@ -48,9 +50,9 @@ describe('global methods', function () {
expect(parseInt(' 42')).toBe(parseInt('42', 10));
expect(parseInt(' 08')).toBe(parseInt('08', 10));
- var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
- '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
- '\u2029\uFEFF';
+ var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003'
+ + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028'
+ + '\u2029\uFEFF';
expect(parseInt(ws + '08')).toBe(parseInt('08', 10));
expect(parseInt(ws + '0x16')).toBe(parseInt('0x16', 16));
});
@@ -69,10 +71,16 @@ describe('global methods', function () {
});
it('NaN parsing', function () {
+ expect(parseInt()).toBeNaN();
expect(parseInt(undefined)).toBeNaN();
expect(parseInt(null)).toBeNaN();
expect(parseInt(NaN)).toBeNaN();
});
+
+ ifSymbolsIt('throws on symbols', function () {
+ expect(function () { parseInt(Symbol('')); }).toThrow();
+ expect(function () { parseInt(Object(Symbol(''))); }).toThrow();
+ });
/* eslint-enable radix */
});
diff --git a/tests/spec/s-object.js b/tests/spec/s-object.js
index 81d637e..47f16f9 100644
--- a/tests/spec/s-object.js
+++ b/tests/spec/s-object.js
@@ -140,7 +140,7 @@ describe('Object', function () {
ifWindowIt('can serialize all objects on the `window`', function () {
var windowItemKeys, exception;
- var blacklistedKeys = ['window', 'console', 'parent', 'self', 'frame', 'frames', 'frameElement', 'external'];
+ var excludedKeys = ['window', 'console', 'parent', 'self', 'frame', 'frames', 'frameElement', 'external', 'height', 'width', 'top', 'localStorage'];
if (supportsDescriptors) {
Object.defineProperty(window, 'thrower', {
configurable: true,
@@ -148,8 +148,9 @@ describe('Object', function () {
});
}
for (var k in window) {
- windowItemKeys = exception = void 0;
- if (blacklistedKeys.indexOf(k) === -1 && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
+ exception = void 0;
+ windowItemKeys = exception;
+ if (excludedKeys.indexOf(k) === -1 && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
try {
windowItemKeys = Object.keys(window[k]);
} catch (e) {
@@ -228,9 +229,7 @@ describe('Object', function () {
it('should not override the parent value', function () {
var child = Object.create(obj, {});
- Object.defineProperty(child, 'name', {
- value: 'Other'
- });
+ Object.defineProperty(child, 'name', { value: 'Other' });
expect(obj.name).toBe('Testing');
expect(child.name).toBe('Other');
@@ -339,11 +338,7 @@ describe('Object', function () {
describe('.defineProperties()', function () {
it('should define the constructor property', function () {
var target = {};
- var newProperties = {
- constructor: {
- value: 'new constructor'
- }
- };
+ var newProperties = { constructor: { value: 'new constructor' } };
Object.defineProperties(target, newProperties);
expect(target.constructor).toBe('new constructor');
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-es5-shim.git
More information about the Pkg-javascript-commits
mailing list