Skip to content

Commit 3658dba

Browse files
CatchABusNathanWalker
authored andcommitted
fix: qualifier matcher did not support multiple qualifiers for a single file. (#9720)
1 parent 03177c2 commit 3658dba

File tree

1 file changed

+6
-5
lines changed
  • packages/core/module-name-resolver/qualifier-matcher

1 file changed

+6
-5
lines changed

packages/core/module-name-resolver/qualifier-matcher/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,21 @@ const supportedQualifiers: Array<QualifierSpec> = [minWidthHeightQualifier, minW
119119

120120
function checkQualifiers(path: string, context: PlatformContext): number {
121121
let result = 0;
122+
let value: number;
122123
for (let i = 0; i < supportedQualifiers.length; i++) {
123124
const qualifier = supportedQualifiers[i];
124125
if (qualifier.isMatch(path)) {
125126
const occurences = qualifier.getMatchOccurences(path);
126127
// Always get the last qualifier among identical occurences
127-
result = qualifier.getMatchValue(occurences[occurences.length - 1], context);
128-
if (result < 0) {
128+
value = qualifier.getMatchValue(occurences[occurences.length - 1], context);
129+
if (value < 0) {
129130
// Non of the supported qualifiers matched this or the match was not satisfied
130131
return -1;
131132
}
132133

133-
result += (supportedQualifiers.length - i) * PRIORITY_STEP;
134-
135-
return result;
134+
if (value > 0) {
135+
result += value + (supportedQualifiers.length - i) * PRIORITY_STEP;
136+
}
136137
}
137138
}
138139

0 commit comments

Comments
 (0)