| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 06646e1 commit 96514a8
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -250,10 +250,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) { | |||
| 250 | 250 | } | |
| 251 | 251 | ||
| 252 | 252 | static Local<Object> createImportAttributesContainer( | |
| 253 | - Environment* env, Isolate* isolate, Local<FixedArray> raw_attributes) { | ||
| 253 | + Environment* env, | ||
| 254 | + Isolate* isolate, | ||
| 255 | + Local<FixedArray> raw_attributes, | ||
| 256 | + const int elements_per_attribute) { | ||
| 257 | + CHECK_EQ(raw_attributes->Length() % elements_per_attribute, 0); | ||
| 254 | 258 | Local<Object> attributes = | |
| 255 | 259 | Object::New(isolate, v8::Null(env->isolate()), nullptr, nullptr, 0); | |
| 256 | - for (int i = 0; i < raw_attributes->Length(); i += 3) { | ||
| 260 | + for (int i = 0; i < raw_attributes->Length(); i += elements_per_attribute) { | ||
| 257 | 261 | attributes | |
| 258 | 262 | ->Set(env->context(), | |
| 259 | 263 | raw_attributes->Get(env->context(), i).As<String>(), | |
@@ -299,7 +303,7 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) { | |||
| 299 | 303 | ||
| 300 | 304 | Local<FixedArray> raw_attributes = module_request->GetImportAssertions(); | |
| 301 | 305 | Local<Object> attributes = | |
| 302 | - createImportAttributesContainer(env, isolate, raw_attributes); | ||
| 306 | + createImportAttributesContainer(env, isolate, raw_attributes, 3); | ||
| 303 | 307 | ||
| 304 | 308 | Local<Value> argv[] = { | |
| 305 | 309 | specifier, | |
@@ -583,7 +587,7 @@ static MaybeLocal<Promise> ImportModuleDynamically( | |||
| 583 | 587 | options->Get(context, HostDefinedOptions::kID).As<Symbol>(); | |
| 584 | 588 | ||
| 585 | 589 | Local<Object> attributes = | |
| 586 | - createImportAttributesContainer(env, isolate, import_attributes); | ||
| 590 | + createImportAttributesContainer(env, isolate, import_attributes, 2); | ||
| 587 | 591 | ||
| 588 | 592 | Local<Value> import_args[] = { | |
| 589 | 593 | id, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,11 @@ async function test() { | |||
| 26 | 26 | { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } | |
| 27 | 27 | ); | |
| 28 | 28 | ||
| 29 | + await rejects( | ||
| 30 | + import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }), | ||
| 31 | + { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } | ||
| 32 | + ); | ||
| 33 | + | ||
| 29 | 34 | await rejects( | |
| 30 | 35 | import(jsModuleDataUrl, { with: { type: 'unsupported' } }), | |
| 31 | 36 | { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,11 @@ await rejects( | |||
| 21 | 21 | { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } | |
| 22 | 22 | ); | |
| 23 | 23 | ||
| 24 | + await rejects( | ||
| 25 | + import(jsModuleDataUrl, { with: { type: 'json', other: 'unsupported' } }), | ||
| 26 | + { code: 'ERR_IMPORT_ASSERTION_TYPE_FAILED' } | ||
| 27 | + ); | ||
| 28 | + | ||
| 24 | 29 | await rejects( | |
| 25 | 30 | import(import.meta.url, { with: { type: 'unsupported' } }), | |
| 26 | 31 | { code: 'ERR_IMPORT_ASSERTION_TYPE_UNSUPPORTED' } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments