@@ -254,10 +254,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
254254}
255255
256256static 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 );
258262 Local<Object> attributes =
259263 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 ) {
261265 attributes
262266 ->Set (realm->context (),
263267 raw_attributes->Get (realm->context (), i).As <String>(),
@@ -303,7 +307,7 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
303307
304308 Local<FixedArray> raw_attributes = module_request->GetImportAssertions ();
305309 Local<Object> attributes =
306- createImportAttributesContainer (realm, isolate, raw_attributes);
310+ createImportAttributesContainer (realm, isolate, raw_attributes, 3 );
307311
308312 Local<Value> argv[] = {
309313 specifier,
@@ -587,7 +591,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
587591 }
588592
589593 Local<Object> attributes =
590- createImportAttributesContainer (realm, isolate, import_attributes);
594+ createImportAttributesContainer (realm, isolate, import_attributes, 2 );
591595
592596 Local<Value> import_args[] = {
593597 id,
0 commit comments