Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(esl-media-query): deprecate ESLMediaRuleList.parse #2498

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/modules/esl-media-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ ESLMediaRuleList.parse('@XS => {option: 1} | @+SM => {option: 2}', evaluate); //
ESLMediaRuleList.parseTuple('@xs|@sm|@md|@lg|@xl', '1|2|3|4|5') // String payload example
ESLMediaRuleList.parseTuple('@xs|@sm|@md|@lg|@xl', '1|2|3|4|5', Number) // Numeric payload sample
```
**Note**: Method `ESLMediaRuleList.parse` is deprecated, and will be reintroduced in ESL v5.0.0 with a different signature. For now use `ESLMediaRuleList.parseTuple` or `ESLMediaRuleList.parseQuery` instead.

#### ESLMediaRuleList API

Expand Down
8 changes: 8 additions & 0 deletions src/modules/esl-media-query/core/esl-media-rule-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
public static OBJECT_PARSER = <U = any>(val: string): U | undefined => evaluate(val);

/**
* @deprecated Method will be reintroduced in v5.0.0 with a different signature. For now use ESLMediaRuleList.parseQuery instead
*
* Creates `ESLMediaRuleList` from string query representation
* Expect serialized {@link ESLMediaRule}s separated by '|'
* Uses exact strings as rule list values
Expand All @@ -43,6 +45,8 @@
*/
public static parse(query: string): ESLMediaRuleList<string>;
/**
* @deprecated Method will be reintroduced in v5.0.0 with a different signature. For now use ESLMediaRuleList.parseQuery instead
*
* Creates `ESLMediaRuleList` from string query representation.
* Expect serialized {@link ESLMediaRule}s separated by '|'
*
Expand All @@ -51,6 +55,8 @@
*/
public static parse<U>(query: string, parser: RulePayloadParser<U>): ESLMediaRuleList<U>;
/**
* @deprecated Method will be reintroduced in v5.0.0 with a different signature. For now use ESLMediaRuleList.parseTuple instead

* Creates `ESLMediaRuleList` from two strings with conditions and values sequences
*
* @param mask - media conditions tuple string (uses '|' as separator)
Expand All @@ -63,6 +69,8 @@
*/
public static parse(mask: string, values: string): ESLMediaRuleList<string>;
/**
* @deprecated Method will be reintroduced in v5.0.0 with a different signature. For now use ESLMediaRuleList.parseTuple instead
*
* Creates `ESLMediaRuleList` from two strings with conditions and values sequences
*
* @param mask - media conditions tuple string (uses '|' as separator)
Expand Down Expand Up @@ -133,7 +141,7 @@
while (valueList.length < queries.length && valueList.length !== 0) valueList.push(valueList[valueList.length - 1]);
if (valueList.length !== queries.length) throw Error('Value doesn\'t correspond to mask');
const rules: (ESLMediaRule | undefined)[] = queries.map((query, i) => ESLMediaRule.create(valueList[i], query, parser));
const validRules = rules.filter((rule) => !!rule) as ESLMediaRule[];

Check warning on line 144 in src/modules/esl-media-query/core/esl-media-rule-list.ts

View workflow job for this annotation

GitHub Actions / Linting

This assertion is unnecessary since it does not change the type of the expression
return new ESLMediaRuleList(validRules);
}

Expand Down
Loading