Skip to content

Commit

Permalink
NodeJS and Deno set codes to deprecated errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Nov 17, 2021
1 parent 00b448d commit 3c83f54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tests/pure/web.dom-exception.constructor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS } from '../helpers/constants';
import { DESCRIPTORS, NODE } from '../helpers/constants';
import DOMException from 'core-js-pure/stable/dom-exception';
import Symbol from 'core-js-pure/es/symbol';

Expand Down Expand Up @@ -58,7 +58,8 @@ QUnit.test('DOMException', assert => {
assert.same(error.message, '42', `new DOMException({}, "${ name }").message`);
assert.same(error.name, name, `new DOMException({}, "${ name }").name`);
if (errors[name].m) assert.same(error.code, errors[name].c, `new DOMException({}, "${ name }").code`);
else assert.same(error.code, 0, `new DOMException({}, "${ name }").code`);
// NodeJS and Deno set codes to deprecated errors
else if (!NODE) assert.same(error.code, 0, `new DOMException({}, "${ name }").code`);
assert.same(String(error), `${ name }: 42`, `String(new DOMException({}, "${ name }"))`); // Safari 10.1 bug
if (HAS_STACK) assert.ok('stack' in error, `'stack' in new DOMException({}, "${ name }")`);

Expand Down
5 changes: 3 additions & 2 deletions tests/tests/web.dom-exception.constructor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DESCRIPTORS } from '../helpers/constants';
import { DESCRIPTORS, NODE } from '../helpers/constants';

const errors = {
IndexSizeError: { s: 'INDEX_SIZE_ERR', c: 1, m: 1 },
Expand Down Expand Up @@ -57,7 +57,8 @@ QUnit.test('DOMException', assert => {
assert.same(error.message, '42', `new DOMException({}, "${ name }").message`);
assert.same(error.name, name, `new DOMException({}, "${ name }").name`);
if (errors[name].m) assert.same(error.code, errors[name].c, `new DOMException({}, "${ name }").code`);
else assert.same(error.code, 0, `new DOMException({}, "${ name }").code`);
// NodeJS and Deno set codes to deprecated errors
else if (!NODE) assert.same(error.code, 0, `new DOMException({}, "${ name }").code`);
assert.same(String(error), `${ name }: 42`, `String(new DOMException({}, "${ name }"))`); // Safari 10.1 bug
if (HAS_STACK) assert.ok('stack' in error, `'stack' in new DOMException({}, "${ name }")`);

Expand Down

0 comments on commit 3c83f54

Please sign in to comment.