Skip to content

Commit

Permalink
use polyfilled DOMException
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 9, 2021
1 parent c876280 commit 894f81d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
10 changes: 1 addition & 9 deletions packages/core-js/modules/web.structured-clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var WebAssembly = global.WebAssembly;
var CompileError = WebAssembly && WebAssembly.CompileError || Error;
var LinkError = WebAssembly && WebAssembly.LinkError || Error;
var RuntimeError = WebAssembly && WebAssembly.RuntimeError || Error;
var DOMException = getBuiltin('DOMException');
var Set = getBuiltin('Set');
var Map = getBuiltin('Map');
var MapPrototype = Map.prototype;
Expand All @@ -48,15 +49,6 @@ var PERFORMANCE_MARK = uid('structuredClone');
var DATA_CLONE_ERROR = 'DataCloneError';
var TRANSFERRING = 'Transferring';

// waiting for https://github.com/zloirock/core-js/pull/991
var DOMException = function (message, name) {
try {
return new global.DOMException(message, name);
} catch (error) {
return TypeError(message);
}
};

var checkBasicSemantic = function (structuredCloneImplementation) {
return !fails(function () {
var set1 = new global.Set([7]);
Expand Down
4 changes: 4 additions & 0 deletions packages/core-js/stable/structured-clone.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
require('../modules/es.error.to-string');
require('../modules/es.array.iterator');
require('../modules/es.object.to-string');
require('../modules/es.map');
require('../modules/es.set');
require('../modules/web.dom-exception.constructor');
require('../modules/web.dom-exception.stack');
require('../modules/web.dom-exception.to-string-tag');
require('../modules/web.structured-clone');
var path = require('../internals/path');

Expand Down
4 changes: 2 additions & 2 deletions tests/pure/web.structured-clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Symbol from 'core-js-pure/es/symbol';
import Map from 'core-js-pure/es/map';
import Set from 'core-js-pure/es/set';
import AggregateError from 'core-js-pure/es/aggregate-error';
import DOMException from 'core-js-pure/stable/dom-exception';

QUnit.module('structuredClone', () => {
QUnit.test('identity', assert => {
Expand Down Expand Up @@ -356,8 +357,7 @@ QUnit.module('structuredClone', () => {
});
});

// TODO: remove check after https://github.com/zloirock/core-js/pull/991
if (fromSource('new DOMException')) QUnit.test('DOMException', assert => {
QUnit.test('DOMException', assert => {
const errors = [
new DOMException(),
new DOMException('foo', 'DataCloneError'),
Expand Down
3 changes: 1 addition & 2 deletions tests/tests/web.structured-clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ QUnit.module('structuredClone', () => {
});
});

// TODO: remove DOMException constructor check after https://github.com/zloirock/core-js/pull/991
if (fromSource('new DOMException')) QUnit.test('DOMException', assert => {
QUnit.test('DOMException', assert => {
const errors = [
new DOMException(),
new DOMException('foo', 'DataCloneError'),
Expand Down

0 comments on commit 894f81d

Please sign in to comment.