Skip to content

Commit 71147ec

Browse files
committed
Replace JavaScript SyntaxError with a DOMException
1 parent 5227c28 commit 71147ec

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

lib/error.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,19 @@ export const EXTRA_RULE_ERROR = {
1414
}
1515
export const INSERT_INVALID_IMPORT_ERROR = {
1616
message: 'Cannot insert @import in a constructed style sheet',
17+
name: 'SyntaxError',
1718
}
1819
export const INVALID_CUSTOM_PROPERTY_NAME = {
1920
message: 'Invalid name',
21+
name: 'SyntaxError',
2022
}
2123
export const INVALID_CUSTOM_PROPERTY_OVERRIDE = {
2224
message: 'Cannot override an existing custom property definition',
25+
name: 'InvalidModificationError',
2326
}
2427
export const INVALID_CUSTOM_PROPERTY_SYNTAX = {
2528
message: 'Invalid syntax',
29+
name: 'SyntaxError',
2630
}
2731
export const INVALID_DECLARATION_ERROR = {
2832
message: 'Cannot parse invalid declaration',
@@ -36,12 +40,15 @@ export const INVALID_FONT_FEATURE_VALUE_ERROR = {
3640
}
3741
export const INVALID_INITIAL_CUSTOM_PROPERTY_VALUE = {
3842
message: 'Invalid initial value',
43+
name: 'SyntaxError',
3944
}
4045
export const INVALID_INITIAL_CUSTOM_PROPERTY_VALUE_UNIVERSAL = {
4146
message: 'Invalid initial value',
47+
name: 'SyntaxError',
4248
}
4349
export const MISSING_INITIAL_CUSTOM_PROPERTY_VALUE = {
4450
message: 'Invalid initial value',
51+
name: 'SyntaxError',
4552
}
4653
export const INVALID_NAMESPACE_STATE_ERROR = {
4754
message: 'Cannot insert @namespace when any other rule than @import or @namespace already exists',
@@ -63,9 +70,11 @@ export const MISSING_RULE_ERROR = {
6370
}
6471
export const SET_INVALID_KEYFRAME_SELECTOR_ERROR = {
6572
message: "Cannot set 'keyText': invalid value",
73+
name: 'SyntaxError',
6674
}
6775
export const SET_INVALID_KEYFRAMES_NAME_ERROR = {
6876
message: "Cannot set 'name': invalid value",
77+
name: 'SyntaxError',
6978
}
7079
export const UPDATE_COMPUTED_STYLE_DECLARATION_ERROR = {
7180
message: 'Cannot change a read-only computed style declaration',

lib/parse/arbitrary.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { create as createError } from '../error.js'
88

99
/**
1010
* @param {object} node
11-
* @returns {SyntaxError}
11+
* @returns {DOMException}
1212
*/
1313
function error({ definition: { name, value } }) {
14-
return createError({ message: `Invalid ${name ?? value}` })
14+
return createError({ message: `Invalid ${name ?? value}`, name: 'SyntaxError' })
1515
}
1616

1717
/**

lib/parse/postprocess.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ const reserved = {
5656

5757
/**
5858
* @param {object} node
59-
* @returns {SyntaxError}
59+
* @returns {DOMException}
6060
*/
6161
function error({ definition: { name, value } }) {
62-
return createError({ message: `Invalid ${name ?? value}` })
62+
return createError({ message: `Invalid ${name ?? value}`, name: 'SyntaxError' })
6363
}
6464

6565
/**

lib/parse/preprocess.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ const MAX_CALCULATION_TERMS = 32
2424

2525
/**
2626
* @param {object} node
27-
* @returns {SyntaxError}
27+
* @returns {DOMException}
2828
*/
2929
function error({ definition: { name, value } }) {
30-
return createError({ message: `Invalid ${name ?? value}` })
30+
return createError({ message: `Invalid ${name ?? value}`, name: 'SyntaxError' })
3131
}
3232

3333
/**

lib/parse/replace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { simplifyCalculation } from './simplify.js'
1010

1111
/**
1212
* @param {object} node
13-
* @returns {SyntaxError}
13+
* @returns {DOMException}
1414
*/
1515
function error({ definition: { name, value } }) {
16-
return createError({ message: `Invalid ${name ?? value}` })
16+
return createError({ message: `Invalid ${name ?? value}`, name: 'SyntaxError' })
1717
}
1818

1919
/**

0 commit comments

Comments
 (0)