Skip to content

Commit 96821d6

Browse files
committed
refactor: Rename feature-related terminology to module-related
1 parent 271e8bc commit 96821d6

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ export {
2121
AstWildcardNamespace,
2222
AstWildcardTag
2323
} from './ast.js';
24-
export {CssLevel, CssFeature, SyntaxDefinition} from './syntax-definitions.js';
24+
export {CssLevel, CssModule, SyntaxDefinition} from './syntax-definitions.js';

src/parser.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,26 +77,26 @@ export function createParser(
7777
*/
7878
strict?: boolean;
7979
/**
80-
* Additional CSS features to include in the syntax definition.
80+
* Additional CSS modules to include in the syntax definition.
8181
* These are specific CSS modules that add new selectors or modify existing ones.
8282
* @example ['css-position-3', 'css-scoping-1']
8383
*/
84-
features?: CssFeature[];
84+
modules?: CssModule[];
8585
} = {}
8686
): Parser {
87-
const {syntax = 'latest', substitutes, strict = true, features} = options;
87+
const {syntax = 'latest', substitutes, strict = true, modules} = options;
8888
let syntaxDefinition: SyntaxDefinition = typeof syntax === 'object' ? syntax : cssSyntaxDefinitions[syntax];
8989

9090
if (syntaxDefinition.baseSyntax) {
9191
syntaxDefinition = extendSyntaxDefinition(cssSyntaxDefinitions[syntaxDefinition.baseSyntax], syntaxDefinition);
9292
}
9393

94-
// Apply additional features if specified
95-
if (features && features.length > 0) {
96-
for (const feature of features) {
97-
const featureSyntax = cssFeatures[feature];
98-
if (featureSyntax) {
99-
syntaxDefinition = extendSyntaxDefinition(syntaxDefinition, featureSyntax);
94+
// Apply additional modules if specified
95+
if (modules && modules.length > 0) {
96+
for (const module of modules) {
97+
const moduleSyntax = cssModules[module];
98+
if (moduleSyntax) {
99+
syntaxDefinition = extendSyntaxDefinition(syntaxDefinition, moduleSyntax);
100100
}
101101
}
102102
}

src/syntax-definitions.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,14 @@ export const cssSyntaxDefinitions: Record<CssLevel, SyntaxDefinition> = {
406406
};
407407

408408
/**
409-
* CSS Feature modules with their syntax definitions.
410-
* These can be used to extend the parser with specific CSS features.
409+
* CSS Modules with their syntax definitions.
410+
* These can be used to extend the parser with specific CSS modules.
411411
*
412412
* @example
413-
* // Using the css-position-3 feature
414-
* createParser({ features: ['css-position-3'] })
413+
* // Using the css-position-3 module
414+
* createParser({ modules: ['css-position-3'] })
415415
*/
416-
export const cssFeatures = {
416+
export const cssModules = {
417417
'css-position-3': {
418418
pseudoClasses: {
419419
definitions: {
@@ -442,8 +442,8 @@ export const cssFeatures = {
442442
} satisfies Record<string, SyntaxDefinition>;
443443

444444
/**
445-
* CSS Feature module name.
445+
* CSS Module name.
446446
* @example 'css-position-3'
447447
* @example 'css-scoping-1'
448448
*/
449-
export type CssFeature = keyof typeof cssFeatures;
449+
export type CssModule = keyof typeof cssModules;

test/features.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {createParser, ast} from './import.js';
22

3-
describe('CSS Features', () => {
3+
describe('CSS Modules', () => {
44
describe('css-position-3', () => {
5-
it('should parse position pseudo-classes when feature is enabled', () => {
5+
it('should parse position pseudo-classes when module is enabled', () => {
66
const parse = createParser({
7-
features: ['css-position-3']
7+
modules: ['css-position-3']
88
});
99

1010
expect(parse(':sticky')).toEqual(
@@ -38,7 +38,7 @@ describe('CSS Features', () => {
3838
);
3939
});
4040

41-
it('should reject position pseudo-classes when feature is not enabled', () => {
41+
it('should reject position pseudo-classes when module is not enabled', () => {
4242
const parse = createParser({
4343
syntax: {
4444
pseudoClasses: {
@@ -178,10 +178,10 @@ describe('CSS Features', () => {
178178
});
179179
});
180180

181-
describe('Multiple features', () => {
182-
it('should support multiple features at once', () => {
181+
describe('Multiple modules', () => {
182+
it('should support multiple modules at once', () => {
183183
const parse = createParser({
184-
features: ['css-position-3', 'css-scoping-1']
184+
modules: ['css-position-3', 'css-scoping-1']
185185
});
186186

187187
// Position pseudo-class

0 commit comments

Comments
 (0)