Skip to content

Commit

Permalink
Ensure Map, Set, and Promise shims all throw when used without …
Browse files Browse the repository at this point in the history
…"new".

Fixes tests in IE 9.
  • Loading branch information
ljharb committed Jun 6, 2015
1 parent 574d95d commit cccdb97
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1849,6 +1849,9 @@
};

var Promise = function Promise(resolver) {
if (!(this instanceof Promise)) {
throw new TypeError('Constructor Promise requires "new"');
}
if (this && this._promise) {
throw new TypeError('Bad construction');
}
Expand Down Expand Up @@ -2201,6 +2204,9 @@
addIterator(MapIterator.prototype);

var MapShim = function Map() {
if (!(this instanceof Map)) {
throw new TypeError('Constructor Map requires "new"');
}
if (this && this._es6map) {
throw new TypeError('Bad construction');
}
Expand Down Expand Up @@ -2408,6 +2414,9 @@
// as backing storage and lazily create a full Map only when
// required.
var SetShim = function Set() {
if (!(this instanceof Set)) {
throw new TypeError('Constructor Set requires "new"');
}
if (this && this._es6set) {
throw new TypeError('Bad construction');
}
Expand Down

0 comments on commit cccdb97

Please sign in to comment.