Skip to content

Commit 002c790

Browse files
committedJul 22, 2020
fix: assign higher precedence to custom selectors
1 parent f9f666e commit 002c790

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed
 

‎packages/otion/src/createInstance.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import {
1414
PROPERTY_ACCEPTS_UNITLESS_VALUES,
1515
PROPERTY_PRECEDENCE_CORRECTION_GROUPS,
1616
} from "./propertyMatchers";
17-
import { PRECEDENCES_BY_PSEUDO_CLASS } from "./pseudos";
17+
import {
18+
PRECEDENCES_BY_PSEUDO_CLASS,
19+
PSEUDO_CLASS_PRECEDENCE_GROUP_COUNT,
20+
} from "./pseudos";
1821

1922
const MAX_CLASS_NAME_LENGTH = 9;
2023
export const PRECEDENCE_GROUP_COUNT = 36;
@@ -210,7 +213,7 @@ export function createInstance(): OtionInstance {
210213
classSelectorStartIndex + 8,
211214
),
212215
)) ||
213-
1;
216+
PSEUDO_CLASS_PRECEDENCE_GROUP_COUNT + 1;
214217

215218
const scopeSelector = `.${className}`;
216219
injector.insert(

‎packages/otion/src/pseudos.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
*/
77

88
export const PRECEDENCES_BY_PSEUDO_CLASS = new Map([
9-
[/* li */ "nk", 2],
10-
[/* vi */ "sited", 3],
11-
[/* em */ "pty", 4],
12-
[/* fo */ "cus-w" /* ithin */, 5],
13-
[/* ho */ "ver", 6],
14-
[/* fo */ "cus", 7],
15-
[/* fo */ "cus-v" /* isible */, 8],
16-
[/* ac */ "tive", 9],
17-
[/* di */ "sable" /* d */, 10],
9+
[/* li */ "nk", 1],
10+
[/* vi */ "sited", 2],
11+
[/* em */ "pty", 3],
12+
[/* fo */ "cus-w" /* ithin */, 4],
13+
[/* ho */ "ver", 5],
14+
[/* fo */ "cus", 6],
15+
[/* fo */ "cus-v" /* isible */, 7],
16+
[/* ac */ "tive", 8],
17+
[/* di */ "sable" /* d */, 9],
1818
]);
19+
20+
export const PSEUDO_CLASS_PRECEDENCE_GROUP_COUNT = 9;

0 commit comments

Comments
 (0)