Lots of updates

This commit is contained in:
baldo 2016-05-16 13:33:49 +02:00
commit 39e7af6238
454 changed files with 221168 additions and 36622 deletions

View file

@ -1,6 +1,5 @@
{
"name": "es5-shim",
"version": "4.0.1",
"main": "es5-shim.js",
"repository": {
"type": "git",
@ -19,8 +18,7 @@
"keywords": [
"shim",
"es5",
"es5",
"shim",
"es5 shim",
"javascript",
"ecmascript",
"polyfill"
@ -32,13 +30,14 @@
"bower_components",
"tests"
],
"_release": "4.0.1",
"version": "4.5.8",
"_release": "4.5.8",
"_resolution": {
"type": "version",
"tag": "v4.0.1",
"commit": "734e4dd80a1e4cbbd3bb6947c79084e86cb1793b"
"tag": "v4.5.8",
"commit": "0472d5096990f512875e98338ca6218d2ce5836f"
},
"_source": "git://github.com/es-shims/es5-shim.git",
"_target": "~4.0.1",
"_source": "https://github.com/es-shims/es5-shim.git",
"_target": "~4.5.8",
"_originalSource": "es5-shim"
}

View file

@ -1,3 +1,247 @@
4.5.8
- [Fix] Check if property descriptor is configurable before re-defining it (#394, #373)
- [Dev Deps] update `eslint`, `jscs`, `@ljharb/eslint-config`
- [Tests] up to `node` `v5.10`, `v4.4`
- [Tests] Use `concurrently` instead of `parallelshell`
- [Tests] use `pretest` to run the linter
4.5.7
- [Fix] `bind` in IE 8: Update `is-callable` implementation to v1.1.3 (#390)
4.5.6
- [Fix] `new Date(new Date())` should work in IE 8 (#389)
- [Tests] on `node` `v5.7`
- [Dev Deps] update `uglify-js`
4.5.5
- [Fix] Adobe Photoshops JS engine bizarrely can have `+date !== date.getTime()` (#365)
- [Dev Deps] update `eslint`
- [Refactor] Update `is-callable` implementation to match latest
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
4.5.4
- [Fix] careless error from 5cf99aca49e59bae03b5d542381424bb1b13ec42
4.5.3
- [Fix] Saturday is a day in the week (#386)
- [Robustness] improve Function#bind (#381)
- [Tests] on `node` `v5.6`, `v4.3`
- [Tests] use json3 (#382)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`
- [Docs] add note about script order (#379)
4.5.2
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.5.1
- [Fix] Make sure preexisting + broken `Array#` methods that throw dont break the runtime (#377)
- [Dev Deps] update `jscs`
4.5.0
- [New] `parseFloat('-0')` should return -0 in Opera 12 (#371)
- [New] Provide and replace Date UTC methods (#360)
- [Robustness] cache `Date` getUTC* methods so that `Date#toISOString` doesnt observably look them up on the receiver
- [Robustness] use a cached and shimmed `String#trim`
- [Tests] up to `node` `v5.5`
- [Tests] add `parallelshell` and use it in a few tasks
- [Refactor] rename cached methods to avoid linter warnings
- [Dev Deps] update `eslint`, `jscs`, '@ljharb/eslint-config'
- [Docs] Update license year to 2016 (#374)
4.4.2
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.4.1
- [Fix] ensure that IE 11 in compatibility mode doesn't throw (#370)
- [Docs] add missing shimmed things
4.4.0
- [New] Detect and patch `RegExp#toString` in IE 8, which returns flags in the wrong order (#364)
- [Fix] Patch `Array#sort` on {Chrome, Safari, IE < 9, FF 4} that throws improperly, per ES5 (#354)
- [Fix] In IE 6, `window.external` makes `Object.keys` throw
- [Fix] `Array#slice`: boxed string access on IE <= 8 (#349)
- [Fix] `Array#join`: fix IE 6-8 join called on string literal (#352)
- [Fix] Ensure that `Error#message` and `Error#name` are non-enumerable (#358)
- [Fix: sham] `Object.getOwnPropertyDescriptor`: In Opera 11.6, `propertyIsEnumerable` is a nonshadowable global, like `toString`
- [Robustness] Use a bound form of `Array#slice.call`
- [Tests] Properly check for descriptor support in IE <= 8
- [Tests] on `node` `v5.1`
- [Tests] Add `Array#slice` tests (#346)
- [Dev Deps] update `uglify-js`, `eslint`, `jscs`, `uglify-js`, `semver`
- [Docs] Fix broken UMD links (#344)
4.3.2
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.3.1
- [Fix] `String#split`: revert part of dcce96ae21185a69d2d40e67416e7496b73e8e47 which broke in older browsers (#342)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
- [Tests] Firefox allows `Number#toPrecision` values of [1,100], which the spec permits
4.3.0
- [New] `Array#push`: in IE <= 7, `Array#push` was not generic (#336)
- [New] `Array#push` in Opera `10.6` has a super weird bug when pushing `undefined`
- [New] `Array#join`: In IE <= 7, passing `undefined` didn't use the default separator (#333)
- [New] `Error#toString`: prints out the proper message in IE 7 and below (#334)
- [New] `Number#toPrecision`: IE 7 and below incorrectly throw when an explicit `undefined` precision is passed (#340)
- [Fix] `String#lastIndexOf`: ensure the correct length in IE 8
- [Fix] ensure `parseInt` accepts negative and plus-prefixed hex values (#332)
- [Robustness] Use a bound `Array#push` instead of relying on `Function#call`
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`
- [Tests] Add some conditionals to avoid impossible-to-fix test failures in IE 6-8, due to it being unable to distinguish between `undefined` and an absent index (#114)
- [Tests] Fix false negatives in IE 6-8 with jasmine comparing arrays to arraylikes (#114)
- [Tests] add additional `Array#shift` tests (#337)
- [Tests] Add additional `Array#splice` tests (#339)
- [Tests] Add `Array#pop` tests, just in case (#338)
- [Tests] include `global` tests in HTML test files
- [Tests] Make sure the HTML tests run with the right charset
- [Tests] ensure `node` `v0.8` tests stay passing.
- [Tests] Prevent nondeterminism in the tests - this sometime produced values that are one ms off
- [Tests] on `node` `v5.0`
- [Tests] fix npm upgrades for older nodes
4.2.1
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.2.0
- [shim: new] Overwrite `String#lastIndexOf` in IE 9, 10, 11, and Edge, so it has proper unicode support.
- [Dev Deps] update `eslint`, `jscs`
4.1.16
- [shim: fix] use `Array#slice`, not `String#slice`, on `String#split` output (#380)
4.1.15
- [shim: fix] new Date + Date.parse: Fix a Safari 8 & 9 bug where the `ms` arg is treated as a signed instead of unsigned int (#329)
- [shim: fix] add 'frame' to blacklisted keys (#330)
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `jscs`, `uglify-js`
- [Tests] on `node` `v4.2`
- [Tests] Date: prevent nondeterminism in the tests - this sometime produced values that are one ms off
4.1.14
- [shim: fix] Wrap more things in a try/catch, because IE sucks and sometimes throws on [[Get]] of window.localStorage (#327)
- [Refactor] Use `ES.ToUint32` instead of inline `>>>`
- [Tests] up to `node` `v4.1`
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `semver`, `jscs`
4.1.13
- [shim: fix] Fix a bug where `Date(x)` threw instead of equalling `String(Date(x))` (#326)
4.1.12
- [fix] Make sure uglify doesn't remove function names
- [shim: fix] Use `is-arguments` implementation; don't call down legacy code path in modern engines (#325)
- [Tests] up to `io.js` `v3.3`
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`
4.1.11
- [shim: fix] Object.keys in Safari 9 has some bugs. (Already fixed in Webkit Nightly)
- [shim: fix] Omit !Date.parse check in the if statement (#323)
- [sham: fix] Fix Object.create sham to not set __proto__ (#301)
- [sham: fix] Add a typeof check to Object.getPrototypeOf (#319, #320)
- [Tests] up to `io.js` `v3.1`
- [Tests] Make sure `Object.getPrototypeOf` tests don't fail when engines implement ES6 semantics
- [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG (#318)
- [Dev Deps] Update `eslint`, `uglify-js`, `jscs`; use my personal shared `eslint` config
4.1.10
- [Fix] Fix IE 8 issue with `window.frameElement` access in a child iframe (#322)
- [Tests] Consolidating `Date.parse` extended year tests
- [Tests] Account for a `Date.parse` precision variance in Safari 8
- [Tests] DRY up some Date.parse tests
- [Tests] Don't create globals in Date tests
- [Tests] Better failure output when an invalid date's toJSON throws
- [Tests] Also compare lengths of array-likes
- [Tests] Extra check on Object.keys(arguments)
- [Tests] Skip appropriate tests when objects aren't extensible/freezeable/sealable
4.1.9
- [Fix] Remove "extended", add "unicode" in `String#split` shim, to match ES6
- [Fix] Object.keys: Preserve the IE 8 dontEnum bugfix, and the automation equality bugfix.
- [Fix] Object.keys: Prevent a deprecation message from showing up in Chrome.
- [Performance] Speed up blacklisted key check for Object.keys automation equality bug.
- [Tests] Test on `io.js` `v2.4`
- [Dev Deps] Update `eslint`, `semver`
4.1.8
- [Fix] Fix an `Object.keys` IE 8 bug where `localStorage.prototype.constructor === localStorage` would throw (#275)
- [Fix] Shimmed `Object.defineProperty` should not throw for an empty descriptor (#315)
- [Fix] Fix `Date#toISOString` in Safari 5.1 (#243)
- [Fix] Use `Object#propertyIsEnumerable` to default the initial "enumerable" value in `Object.getOwnPropertyDescriptor` sham (#289)
- [Fix] Fix `Array#splice` with large sparse arrays in Safari 7/8, and Opera 12.15 (#295)
- [Robustness] Safely use and reference many builtins internally (also see #313)
- [Tests] Add `Date#{getUTCDate,getUTCMonth}` tests to expose Opera 10.6/11.61/12 `Date` bugs
- [Dev Deps] Update `eslint`
4.1.7
- Make sure `Date.parse` is not enumerable (#310)
4.1.6
- Support IE 8 when `document.domain` is set (#306, #150)
- Remove version from `bower.json` (#307)
4.1.5
- Add a failing runtime check for Safari 8 `Date.parse`
- Update `eslint`, `semver`
- Test on `io.js` `v2.2`
4.1.4
- Make sure copied `Date` properties remain non-enumerable.
- Using a more reliable check for supported property descriptors in non-IE ES3
- Fix 'constructor' in Object.defineProperties sham in ES3 (#252, #305)
- Use a reference to `Array#concat` rather than relying on the runtime environment's `concat`.
- Test on `io.js` `v2.1`
- Clean up `Array.prototype` iteration methods
4.1.3
- Update `license` in `package.json` per https://docs.npmjs.com/files/package.json#license
- Update `uglify-js`, `eslint`
4.1.2
- In IE 6-8, `Date` inside the function expression does not reference `DateShim` (#303)
- Date: Ensure all code paths have the correct `constructor` property
- Date: Don't copy non-own properties from original `Date`
- Test up to `io.js` `v2.0.0`
- Simplify `isPrimitive` check.
- Adding sanity check tests for ES5 `Number` constants.
- Update `uglify-js`, `eslint`, `semver`
4.1.1
- Fix name of `parseInt` replacement.
- Update copyright year
- Update `eslint`, `jscs`
- Lock `uglify-js` down to v2.4.17, since v2.4.18 and v2.4.19 have a breaking change.
- All grade A-supported `node`/`iojs` versions now ship with an `npm` that understands `^`.
- Run `travis-ci` tests on latest `node` and `iojs`; speed up builds; allow 0.8 failures.
- Ensure some Object tests don't fail in ES6
- Make sure `Date` instances don't have an enumerable `constructor` property, when possible.
4.1.0
- Update `eslint`
- Improve type checks: `Array.isArray`, `isRegex`
- Replace `isRegex`/`isString`/`isCallable` checks with inlined versions from npm modules
- Note which ES abstract methods are replaceable via `es-abstract`
- Run `travis-ci` tests on `iojs`!
4.0.6
- Update `jscs`, `uglify-js`, add `eslint`
- es5-sham: fix Object.defineProperty to not check for own properties (#211)
- Fix Array#splice bug in Safari 5 (#284)
- Fix `Object.keys` issue with boxed primitives with extra properties in older browsers. (#242, #285)
4.0.5
- Update `jscs` so tests pass
4.0.4
- Style/indentation/whitespace cleanups.
- README tweaks
4.0.3
- Fix keywords (#268)
- add some Date tests
- Note in README that the es5-sham requires the es5-shim (https://github.com/es-shims/es5-shim/issues/256#issuecomment-52875710)
4.0.2
- Start including version numbers in minified files (#267)
4.0.1
- Fix legacy arguments object detection in Object.keys (#260)

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (C) 2009-2014 Kristopher Michael Kowal and contributors
Copyright (C) 2009-2016 Kristopher Michael Kowal and contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

63
app/bower_components/es5-shim/Makefile vendored Normal file
View file

@ -0,0 +1,63 @@
# Since we rely on paths relative to the makefile location, abort if make isn't being run from there.
$(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in))
# The files that need updating when incrementing the version number.
VERSIONED_FILES := *.js *.json *.map README*
# Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly.
# Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment
# where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests.
export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH")
UTILS := semver
# Make sure that all required utilities can be located.
UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS)))
# Default target (by virtue of being the first non '.'-prefixed in the file).
.PHONY: _no-target-specified
_no-target-specified:
$(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests)
# Lists all targets defined in this makefile.
.PHONY: list
list:
@$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort
# All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS).
.PHONY: test
test:
@npm test
.PHONY: _ensure-tag
_ensure-tag:
ifndef TAG
$(error Please invoke with `make TAG=<new-version> release`, where <new-version> is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number)
endif
CHANGELOG_ERROR = $(error No CHANGES specified)
.PHONY: _ensure-changelog
_ensure-changelog:
@ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGES' > /dev/null) || (echo no CHANGES specified && exit 2)
# Ensures that the git workspace is clean.
.PHONY: _ensure-clean
_ensure-clean:
@[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGES')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; }
# Makes a release; invoke with `make TAG=<versionOrIncrementSpec> release`.
.PHONY: release
release: _ensure-tag _ensure-changelog _ensure-clean
@old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \
new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \
if printf "$$new_ver" | command grep -q '^[0-9]'; then \
semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \
semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \
else \
new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \
fi; \
printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \
npm run minify; \
replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \
replace "blob/master" "blob/v$$new_ver" -- *.min.js && \
git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGES && \
git tag -a -m "v$$new_ver" "v$$new_ver"

View file

@ -1,12 +1,16 @@
#es5-shim <sup>[![Version Badge][2]][1]</sup>
#es5-shim <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>
[![npm badge][9]][1]
[![npm badge][npm-badge-png]][npm-url]
[![Build Status][3]][4] [![dependency status][5]][6] [![dev dependency status][7]][8]
[![Build Status][travis-svg]][travis-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
`es5-shim.js` and `es5-shim.min.js` monkey-patch a JavaScript context to
contain all EcmaScript 5 methods that can be faithfully emulated with a
legacy JavaScript engine.
**Note:** As `es5-shim.js` is designed to patch the native Javascript
engine, it should be the library that is loaded first.
`es5-sham.js` and `es5-sham.min.js` monkey-patch other ES5 methods as
closely as possible. For these methods, as closely as possible to ES5
@ -14,12 +18,14 @@ is not very close. Many of these shams are intended only to allow code
to be written to ES5 without causing run-time errors in older engines.
In many cases, this means that these shams cause many ES5 methods to
silently fail. Decide carefully whether this is what you want.
**Note:** `es5-sham.js` requires `es5-shim.js` to be able to work properly.
## Tests
The tests are written with the Jasmine BDD test framework.
To run the tests, navigate to <root-folder>/tests/.
To run the tests, navigate to <root-folder>/tests/ , or,
simply `npm install` and `npm test`.
## Shims
@ -31,9 +37,13 @@ To run the tests, navigate to <root-folder>/tests/.
* Array.prototype.indexOf
* Array.prototype.lastIndexOf
* Array.prototype.map
* Array.prototype.slice
* Array.prototype.some
* Array.prototype.sort
* Array.prototype.reduce
* Array.prototype.reduceRight
* Array.prototype.push
* Array.prototype.join
* Array.isArray
* Date.now
* Date.prototype.toJSON
@ -44,14 +54,21 @@ To run the tests, navigate to <root-folder>/tests/.
* :warning: Caveat: bound functions don't have checks in ``call`` and
``apply`` to avoid executing as a constructor.
* Number.prototype.toFixed
* Number.prototype.toPrecision
* Object.keys
* String.prototype.split
* String.prototype.trim
* String.prototype.lastIndexOf
* String.prototype.replace
* Firefox (through v29) natively handles capturing groups incorrectly.
* Date.parse (for ISO parsing)
* Date.prototype.toISOString
* parseInt
* parseFloat
* Error.prototype.toString
* Error.prototype.name
* Error.prototype.message
* RegExp.prototype.toString
## Shams
@ -62,7 +79,7 @@ To run the tests, navigate to <root-folder>/tests/.
engines.
:warning: The second argument is passed to Object.defineProperties
which will probably fail either silently or with extreme predudice.
which will probably fail either silently or with extreme prejudice.
* :warning: Object.getPrototypeOf
@ -128,7 +145,7 @@ To run the tests, navigate to <root-folder>/tests/.
* :warning: Object.defineProperties
This uses the Object.defineProperty shim
This uses the Object.defineProperty shim.
* Object.seal
@ -151,13 +168,23 @@ To run the tests, navigate to <root-folder>/tests/.
provisions of this method, which you cannot possibly
obtain in legacy engines.
[1]: https://npmjs.org/package/es5-shim
[2]: http://vb.teelaun.ch/es-shims/es5-shim.svg
[3]: https://travis-ci.org/es-shims/es5-shim.png
[4]: https://travis-ci.org/es-shims/es5-shim
[5]: https://david-dm.org/es-shims/es5-shim.png
[6]: https://david-dm.org/es-shims/es5-shim
[7]: https://david-dm.org/es-shims/es5-shim/dev-status.png
[8]: https://david-dm.org/es-shims/es5-shim#info=devDependencies
[9]: https://nodei.co/npm/es5-shim.png?downloads=true&stars=true
### Example of applying ES compatability shims in a browser project
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.7/es5-sham.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json3/3.3.2/json3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-shim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es6-shim/0.34.2/es6-sham.min.js"></script>
<script src="https://wzrd.in/standalone/es7-shim@latest"></script>
<script src="other-libs.js"></script>
```
[npm-url]: https://npmjs.org/package/es5-shim
[npm-version-svg]: http://versionbadg.es/es-shims/es5-shim.svg
[travis-svg]: https://travis-ci.org/es-shims/es5-shim.svg
[travis-url]: https://travis-ci.org/es-shims/es5-shim
[deps-svg]: https://david-dm.org/es-shims/es5-shim.svg
[deps-url]: https://david-dm.org/es-shims/es5-shim
[dev-deps-svg]: https://david-dm.org/es-shims/es5-shim/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/es5-shim#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/es5-shim.png?downloads=true&stars=true

View file

@ -1,6 +1,5 @@
{
"name": "es5-shim",
"version": "4.0.1",
"main": "es5-shim.js",
"repository": {
"type": "git",
@ -19,8 +18,7 @@
"keywords": [
"shim",
"es5",
"es5",
"shim",
"es5 shim",
"javascript",
"ecmascript",
"polyfill"

View file

@ -2,12 +2,11 @@
"name": "es5-shim",
"repo": "es-shims/es5-shim",
"description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
"version": "v4.0.1",
"version": "v4.5.1",
"keywords": [
"shim",
"es5",
"es5",
"shim",
"es5 shim",
"javascript",
"ecmascript",
"polyfill"

View file

@ -1,17 +1,20 @@
/*!
* https://github.com/es-shims/es5-shim
* @license es5-shim Copyright 2009-2014 by contributors, MIT License
* @license es5-shim Copyright 2009-2015 by contributors, MIT License
* see https://github.com/es-shims/es5-shim/blob/master/LICENSE
*/
// vim: ts=4 sts=4 sw=4 expandtab
//Add semicolon to prevent IIFE from being passed as argument to concated code.
// Add semicolon to prevent IIFE from being passed as argument to concatenated code.
;
// UMD (Universal Module Definition)
// see https://github.com/umdjs/umd/blob/master/returnExports.js
// see https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function (root, factory) {
'use strict';
/* global define, exports, module */
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(factory);
@ -26,21 +29,25 @@
}
}(this, function () {
var call = Function.prototype.call;
var call = Function.call;
var prototypeOfObject = Object.prototype;
var owns = call.bind(prototypeOfObject.hasOwnProperty);
var isEnumerable = call.bind(prototypeOfObject.propertyIsEnumerable);
var toStr = call.bind(prototypeOfObject.toString);
// If JS engine supports accessors creating shortcuts.
var defineGetter;
var defineSetter;
var lookupGetter;
var lookupSetter;
var supportsAccessors = owns(prototypeOfObject, "__defineGetter__");
var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
if (supportsAccessors) {
/* eslint-disable no-underscore-dangle */
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 */
}
// ES5 15.2.3.2
@ -54,48 +61,53 @@ if (!Object.getPrototypeOf) {
// ... this will nerever possibly return null
// ... Opera Mini breaks here with infinite loops
Object.getPrototypeOf = function getPrototypeOf(object) {
/* eslint-disable no-proto */
var proto = object.__proto__;
/* eslint-enable no-proto */
if (proto || proto === null) {
return proto;
} else if (object.constructor) {
} else if (toStr(object.constructor) === '[object Function]') {
return object.constructor.prototype;
} else if (object instanceof Object) {
return prototypeOfObject;
} else {
return prototypeOfObject;
// Correctly return null for Objects created with `Object.create(null)`
// (shammed or native) or `{ __proto__: null}`. Also returns null for
// cross-realm objects on browsers that lack `__proto__` support (like
// IE <11), but that's the best we can do.
return null;
}
};
}
//ES5 15.2.3.3
//http://es5.github.com/#x15.2.3.3
// ES5 15.2.3.3
// http://es5.github.com/#x15.2.3.3
function doesGetOwnPropertyDescriptorWork(object) {
var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
try {
object.sentinel = 0;
return Object.getOwnPropertyDescriptor(
object,
"sentinel"
).value === 0;
return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
} catch (exception) {
// returns falsy
return false;
}
}
};
//check whether getOwnPropertyDescriptor works if it's given. Otherwise,
//shim partially.
// 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;
}
}
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
/* eslint-disable no-proto */
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
if ((typeof object !== "object" && typeof object !== "function") || object === null) {
if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
throw new TypeError(ERR_NON_OBJECT + object);
}
@ -109,14 +121,19 @@ if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
}
}
var descriptor;
// If object does not owns property return undefined immediately.
if (!owns(object, property)) {
return;
return descriptor;
}
// If object has a property then it's for sure both `enumerable` and
// `configurable`.
var descriptor = { enumerable: true, configurable: true };
// If object has a property then it's for sure `configurable`, and
// probably `enumerable`. Detect enumerability though.
descriptor = {
enumerable: isEnumerable(object, property),
configurable: true
};
// If JS engine supports accessor properties then property may be a
// getter or setter.
@ -162,6 +179,7 @@ if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
descriptor.writable = true;
return descriptor;
};
/* eslint-enable no-proto */
}
// ES5 15.2.3.4
@ -178,13 +196,73 @@ if (!Object.create) {
// Contributed by Brandon Benvie, October, 2012
var createEmpty;
var supportsProto = !({__proto__:null} instanceof Object);
var supportsProto = !({ __proto__: null } instanceof Object);
// 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
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
/* global ActiveXObject */
var shouldUseActiveX = function shouldUseActiveX() {
// return early if document.domain not set
if (!document.domain) {
return false;
}
try {
return !!new ActiveXObject('htmlfile');
} catch (exception) {
return false;
}
};
// This supports IE8 when document.domain is used
// see https://github.com/es-shims/es5-shim/issues/150
// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
var getEmptyViaActiveX = function getEmptyViaActiveX() {
var empty;
var xDoc;
xDoc = new ActiveXObject('htmlfile');
var script = 'script';
xDoc.write('<' + script + '></' + script + '>');
xDoc.close();
empty = xDoc.parentWindow.Object.prototype;
xDoc = null;
return empty;
};
// The original implementation using an iframe
// before the activex approach was added
// see https://github.com/es-shims/es5-shim/issues/150
var getEmptyViaIFrame = function getEmptyViaIFrame() {
var iframe = document.createElement('iframe');
var parent = document.body || document.documentElement;
var empty;
iframe.style.display = 'none';
parent.appendChild(iframe);
/* eslint-disable no-script-url */
iframe.src = 'javascript:';
/* eslint-enable no-script-url */
empty = iframe.contentWindow.Object.prototype;
parent.removeChild(iframe);
iframe = null;
return empty;
};
/* global document */
if (supportsProto || typeof document === 'undefined') {
createEmpty = function () {
return { "__proto__": null };
return { __proto__: null };
};
} else {
// In old IE __proto__ can't be used to manually set `null`, nor does
@ -193,14 +271,10 @@ if (!Object.create) {
// object and *steal* its Object.prototype and strip it bare. This is
// used as the prototype to create nullary objects.
createEmpty = function () {
var iframe = document.createElement('iframe');
var parent = document.body || document.documentElement;
iframe.style.display = 'none';
parent.appendChild(iframe);
iframe.src = 'javascript:';
var empty = iframe.contentWindow.Object.prototype;
parent.removeChild(iframe);
iframe = null;
// Determine which approach to use
// see https://github.com/es-shims/es5-shim/issues/150
var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
delete empty.constructor;
delete empty.hasOwnProperty;
delete empty.propertyIsEnumerable;
@ -208,9 +282,8 @@ if (!Object.create) {
delete empty.toLocaleString;
delete empty.toString;
delete empty.valueOf;
empty.__proto__ = null;
function Empty() {}
var Empty = function Empty() {};
Empty.prototype = empty;
// short-circuit future calls
createEmpty = function () {
@ -223,18 +296,18 @@ if (!Object.create) {
Object.create = function create(prototype, properties) {
var object;
function Type() {} // An empty constructor.
var Type = function Type() {}; // An empty constructor.
if (prototype === null) {
object = createEmpty();
} else {
if (typeof prototype !== "object" && typeof prototype !== "function") {
if (typeof prototype !== 'object' && typeof prototype !== 'function') {
// In the native implementation `parent` can be `null`
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
// like they are in modern browsers. Using `Object.create` on DOM elements
// is...err...probably inappropriate, but the native version allows for it.
throw new TypeError("Object prototype may only be an Object or null"); // same msg as Chrome
throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
}
Type.prototype = prototype;
object = new Type();
@ -242,7 +315,9 @@ if (!Object.create) {
// 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 */
object.__proto__ = prototype;
/* eslint-enable no-proto */
}
if (properties !== void 0) {
@ -265,21 +340,21 @@ if (!Object.create) {
// WebKit Bugs:
// https://bugs.webkit.org/show_bug.cgi?id=36423
function doesDefinePropertyWork(object) {
var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
try {
Object.defineProperty(object, "sentinel", {});
return "sentinel" in object;
Object.defineProperty(object, 'sentinel', {});
return 'sentinel' in object;
} catch (exception) {
// returns falsy
return false;
}
}
};
// check whether defineProperty works if it's given. Otherwise,
// 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;
@ -287,16 +362,15 @@ if (Object.defineProperty) {
}
if (!Object.defineProperty || definePropertyFallback) {
var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
"on this javascript engine";
var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
Object.defineProperty = function defineProperty(object, property, descriptor) {
if ((typeof object !== "object" && typeof object !== "function") || object === null) {
if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
}
if ((typeof descriptor !== "object" && typeof descriptor !== "function") || descriptor === null) {
if ((typeof descriptor !== 'object' && typeof descriptor !== 'function') || descriptor === null) {
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
}
// make a valiant attempt to use the real defineProperty
@ -310,29 +384,27 @@ if (!Object.defineProperty || definePropertyFallback) {
}
// If it's a data property.
if (owns(descriptor, "value")) {
// fail silently if "writable", "enumerable", or "configurable"
if ('value' in descriptor) {
// fail silently if 'writable', 'enumerable', or 'configurable'
// are requested but not supported
/*
// alternate approach:
if ( // can't implement these features; allow false but not true
!(owns(descriptor, "writable") ? descriptor.writable : true) ||
!(owns(descriptor, "enumerable") ? descriptor.enumerable : true) ||
!(owns(descriptor, "configurable") ? descriptor.configurable : true)
)
('writable' in descriptor && !descriptor.writable) ||
('enumerable' in descriptor && !descriptor.enumerable) ||
('configurable' in descriptor && !descriptor.configurable)
))
throw new RangeError(
"This implementation of Object.defineProperty does not " +
"support configurable, enumerable, or writable."
'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
);
*/
if (supportsAccessors && (lookupGetter(object, property) ||
lookupSetter(object, property)))
{
if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
// As accessors are supported only on engines implementing
// `__proto__` we can safely override `__proto__` while defining
// a property to make sure that we don't hit an inherited
// accessor.
/* eslint-disable no-proto */
var prototype = object.__proto__;
object.__proto__ = prototypeOfObject;
// Deleting a property anyway since getter / setter may be
@ -341,18 +413,19 @@ if (!Object.defineProperty || definePropertyFallback) {
object[property] = descriptor.value;
// Setting original `__proto__` back now.
object.__proto__ = prototype;
/* eslint-enable no-proto */
} else {
object[property] = descriptor.value;
}
} else {
if (!supportsAccessors) {
if (!supportsAccessors && (('get' in descriptor) || ('set' in descriptor))) {
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
}
// If we got that far then getters and setters can be defined !!
if (owns(descriptor, "get")) {
if ('get' in descriptor) {
defineGetter(object, property, descriptor.get);
}
if (owns(descriptor, "set")) {
if ('set' in descriptor) {
defineSetter(object, property, descriptor.set);
}
}
@ -373,11 +446,11 @@ if (!Object.defineProperties || definePropertiesFallback) {
}
}
for (var property in properties) {
if (owns(properties, property) && property !== "__proto__") {
Object.keys(properties).forEach(function (property) {
if (property !== '__proto__') {
Object.defineProperty(object, property, properties[property]);
}
}
});
return object;
};
}
@ -386,6 +459,9 @@ if (!Object.defineProperties || definePropertiesFallback) {
// http://es5.github.com/#x15.2.3.8
if (!Object.seal) {
Object.seal = function seal(object) {
if (Object(object) !== object) {
throw new TypeError('Object.seal can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
@ -397,6 +473,9 @@ if (!Object.seal) {
// http://es5.github.com/#x15.2.3.9
if (!Object.freeze) {
Object.freeze = function freeze(object) {
if (Object(object) !== object) {
throw new TypeError('Object.freeze can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
@ -408,21 +487,24 @@ if (!Object.freeze) {
try {
Object.freeze(function () {});
} catch (exception) {
Object.freeze = (function freeze(freezeObject) {
Object.freeze = (function (freezeObject) {
return function freeze(object) {
if (typeof object === "function") {
if (typeof object === 'function') {
return object;
} else {
return freezeObject(object);
}
};
})(Object.freeze);
}(Object.freeze));
}
// ES5 15.2.3.10
// http://es5.github.com/#x15.2.3.10
if (!Object.preventExtensions) {
Object.preventExtensions = function preventExtensions(object) {
if (Object(object) !== object) {
throw new TypeError('Object.preventExtensions can only be called on Objects.');
}
// this is misleading and breaks feature-detection, but
// allows "securable" code to "gracefully" degrade to working
// but insecure code.
@ -434,6 +516,9 @@ if (!Object.preventExtensions) {
// http://es5.github.com/#x15.2.3.11
if (!Object.isSealed) {
Object.isSealed = function isSealed(object) {
if (Object(object) !== object) {
throw new TypeError('Object.isSealed can only be called on Objects.');
}
return false;
};
}
@ -442,6 +527,9 @@ if (!Object.isSealed) {
// http://es5.github.com/#x15.2.3.12
if (!Object.isFrozen) {
Object.isFrozen = function isFrozen(object) {
if (Object(object) !== object) {
throw new TypeError('Object.isFrozen can only be called on Objects.');
}
return false;
};
}
@ -452,7 +540,7 @@ if (!Object.isExtensible) {
Object.isExtensible = function isExtensible(object) {
// 1. If Type(O) is not Object throw a TypeError exception.
if (Object(object) !== object) {
throw new TypeError(); // TODO message
throw new TypeError('Object.isExtensible can only be called on Objects.');
}
// 2. Return the Boolean value of the [[Extensible]] internal property of O.
var name = '';
@ -467,4 +555,3 @@ if (!Object.isExtensible) {
}
}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "es5-shim",
"version": "4.0.1",
"version": "4.5.8",
"description": "ECMAScript 5 compatibility shims for legacy JavaScript engines",
"homepage": "http://github.com/es-shims/es5-shim/",
"contributors": [
@ -15,29 +15,33 @@
"mail": "ljharb@gmail.com",
"url": "http://github.com/es-shims/es5-shim/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/es-shims/es5-shim/raw/master/LICENSE"
}
],
"license": "MIT",
"main": "es5-shim.js",
"repository": {
"type": "git",
"url": "http://github.com/es-shims/es5-shim.git"
},
"scripts": {
"minify": "npm run minify-shim && npm run minify-sham",
"minify-shim": "uglifyjs es5-shim.js --comments --source-map=es5-shim.map -m -b ascii_only=true,beautify=false > es5-shim.min.js",
"minify-sham": "uglifyjs es5-sham.js --comments --source-map=es5-sham.map -m -b ascii_only=true,beautify=false > es5-sham.min.js",
"test": "jasmine-node --matchall ./ tests/spec/",
"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",
"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": "jscs tests/helpers/*.js tests/spec/*.js es5-shim.js es5-sham.js"
"lint": "concurrently --raw '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": {
"jasmine-node": "~1.14.5",
"jscs": "~1.5.8",
"uglify-js": "~2.4.14"
"eslint": "^2.7.0",
"@ljharb/eslint-config": "^2.2.0",
"jasmine-node": "^1.14.5",
"jscs": "^2.11.0",
"uglify-js": "^2.6.2",
"replace": "^0.3.0",
"semver": "^5.1.0",
"concurrently": "^2.0.0"
},
"engines": {
"node": ">=0.4.0"
@ -58,6 +62,14 @@
"iphone/6.0..latest",
"android-browser/4.2"
]
}
},
"keywords": [
"shim",
"es5",
"es5 shim",
"javascript",
"ecmascript",
"polyfill"
]
}