Skip to content

Commit 6ff53c0

Browse files
committed
Bug 1720570 - Handle css module in GetModuleType; r=allstarschh
Differential Revision: https://phabricator.services.mozilla.com/D263411
1 parent cf4c677 commit 6ff53c0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

js/src/builtin/ModuleObject.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,25 @@ static bool GetModuleType(JSContext* cx,
218218
JS::ModuleType& moduleType) {
219219
for (const ImportAttribute& importAttribute : maybeAttributes) {
220220
if (importAttribute.key() == cx->names().type) {
221-
int32_t isJsonString;
221+
int32_t result;
222222
if (!js::CompareStrings(cx, cx->names().json, importAttribute.value(),
223-
&isJsonString)) {
223+
&result)) {
224224
return false;
225225
}
226-
227-
if (isJsonString == 0) {
226+
if (result == 0) {
228227
moduleType = JS::ModuleType::JSON;
229228
return true;
230229
}
231230

231+
if (!js::CompareStrings(cx, cx->names().css, importAttribute.value(),
232+
&result)) {
233+
return false;
234+
}
235+
if (result == 0) {
236+
moduleType = JS::ModuleType::CSS;
237+
return true;
238+
}
239+
232240
moduleType = JS::ModuleType::Unknown;
233241
return true;
234242
}

js/src/vm/CommonPropertyNames.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
MACRO_(currency, "currency") \
9999
MACRO_(currencyDisplay, "currencyDisplay") \
100100
MACRO_(currencySign, "currencySign") \
101+
MACRO_(css, "css") \
101102
MACRO_(date, "date") \
102103
MACRO_(dateStyle, "dateStyle") \
103104
MACRO_(day, "day") \

0 commit comments

Comments
 (0)