@@ -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,
@@ -579,7 +583,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
579
583
}
580
584
581
585
Local<Object> attributes =
582
- createImportAttributesContainer (env, isolate, import_attributes);
586
+ createImportAttributesContainer (env, isolate, import_attributes, 2 );
583
587
584
588
Local<Value> import_args[] = {
585
589
id,
0 commit comments