@@ -254,10 +254,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
254
254
}
255
255
256
256
static Local<Object> createImportAttributesContainer (
257
- Realm* realm, Isolate* isolate, Local<FixedArray> raw_attributes) {
257
+ Realm* realm,
258
+ Isolate* isolate,
259
+ Local<FixedArray> raw_attributes,
260
+ const int elements_per_attribute) {
261
+ CHECK_EQ (raw_attributes->Length () % elements_per_attribute, 0 );
258
262
Local<Object> attributes =
259
263
Object::New (isolate, v8::Null (isolate), nullptr , nullptr , 0 );
260
- for (int i = 0 ; i < raw_attributes->Length (); i += 3 ) {
264
+ for (int i = 0 ; i < raw_attributes->Length (); i += elements_per_attribute ) {
261
265
attributes
262
266
->Set (realm->context (),
263
267
raw_attributes->Get (realm->context (), i).As <String>(),
@@ -303,7 +307,7 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
303
307
304
308
Local<FixedArray> raw_attributes = module_request->GetImportAssertions ();
305
309
Local<Object> attributes =
306
- createImportAttributesContainer (realm, isolate, raw_attributes);
310
+ createImportAttributesContainer (realm, isolate, raw_attributes, 3 );
307
311
308
312
Local<Value> argv[] = {
309
313
specifier,
@@ -587,7 +591,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
587
591
}
588
592
589
593
Local<Object> attributes =
590
- createImportAttributesContainer (realm, isolate, import_attributes);
594
+ createImportAttributesContainer (realm, isolate, import_attributes, 2 );
591
595
592
596
Local<Value> import_args[] = {
593
597
id,
0 commit comments