Skip to content

Commit db04f00

Browse files
committed
Switch to ES modules
With some minor refactorings and fixes alongside.
1 parent dc00979 commit db04f00

File tree

120 files changed

+1698
-3428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+1698
-3428
lines changed

__tests__/css.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
const { install } = require('../lib/index.js')
3-
const {
2+
import {
43
INVALID_CUSTOM_PROPERTY_NAME,
54
INVALID_CUSTOM_PROPERTY_OVERRIDE,
65
INVALID_CUSTOM_PROPERTY_SYNTAX,
76
INVALID_INITIAL_CUSTOM_PROPERTY_VALUE,
87
INVALID_INITIAL_CUSTOM_PROPERTY_VALUE_UNIVERSAL,
98
MISSING_INITIAL_CUSTOM_PROPERTY_VALUE,
10-
} = require('../lib/cssom/CSS-impl.js')
9+
} from '../lib/error.js'
10+
import { install } from '../lib/index.js'
1111

1212
install()
1313
globalThis.document = { _registeredPropertySet: [] }

__tests__/definition.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
const nonTerminal = require('../lib/values/definitions.js')
3-
const parseDefinition = require('../lib/parse/definition.js')
4-
const properties = require('../lib/properties/definitions.js')
5-
const { serializeDefinition: serialize } = require('../lib/serialize.js')
2+
import nonTerminal from '../lib/values/definitions.js'
3+
import parseDefinition from '../lib/parse/definition.js'
4+
import properties from '../lib/properties/definitions.js'
5+
import { serializeDefinition as serialize } from '../lib/serialize.js'
66

77
/**
88
* @param {...object} value
@@ -611,12 +611,12 @@ describe('errors', () => {
611611
'a{2}!',
612612
'a{0,∞}?',
613613
'a{1,∞}?',
614-
`a?{2}`,
615-
`a??`,
616-
`a?*`,
617-
`a?+`,
618-
`a?#`,
619-
`a?!`,
614+
'a?{2}',
615+
'a??',
616+
'a?*',
617+
'a?+',
618+
'a?#',
619+
'a?!',
620620
'a*{2}',
621621
'a*?',
622622
'a**',
@@ -632,12 +632,12 @@ describe('errors', () => {
632632
'a#+',
633633
'a##',
634634
'a#!',
635-
`a!{2}`,
636-
`a!?`,
637-
`a!*`,
638-
`a!+`,
639-
`a!#`,
640-
`a!!`,
635+
'a!{2}',
636+
'a!?',
637+
'a!*',
638+
'a!+',
639+
'a!#',
640+
'a!!',
641641
]
642642
invalid.forEach(input => expect(() => parse(input)).toThrow())
643643
})

__tests__/match.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11

2-
const { install } = require('../lib/index.js')
3-
// Do not import CSSOM implementations before the above import
4-
const matchMediaQueryList = require('../lib/match/media.js')
5-
const matchSupport = require('../lib/match/support.js')
6-
const { parseCSSGrammar } = require('../lib/parse/parser.js')
2+
import { install } from '../lib/index.js'
3+
import matchMediaQueryList from '../lib/match/media.js'
4+
import matchSupport from '../lib/match/support.js'
5+
import { parseCSSGrammar } from '../lib/parse/parser.js'
76

87
install()
98

__tests__/media.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

2-
const { cssom, install } = require('../lib/index.js')
3-
// Do not import CSSOM implementations before the above import
4-
const { DELETE_UNEXISTENT_MEDIUM_ERROR } = require('../lib/cssom/MediaList-impl.js')
2+
import { cssom, install } from '../lib/index.js'
3+
import { DELETE_UNEXISTENT_MEDIUM_ERROR } from '../lib/error.js'
54

65
install()
76

__tests__/permutation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
const { createPermutationIterator, getNthPermutation, getPermutationIndex } = require('../lib/parse/permutation.js')
2+
import { createPermutationIterator, getNthPermutation, getPermutationIndex } from '../lib/parse/permutation.js'
33

44
const a = { type: 'keyword', value: 'a' }
55
const b = { type: 'keyword', value: 'b' }

__tests__/stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
const Stream = require('../lib/parse/stream.js')
2+
import Stream from '../lib/parse/stream.js'
33

44
const string = 'hello'
55
const stream = new Stream(string)

0 commit comments

Comments
 (0)