@@ -251,10 +251,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
251251}
252252
253253static Local<Object> createImportAttributesContainer (
254- Environment* env, Isolate* isolate, Local<FixedArray> raw_attributes) {
254+ Environment* env,
255+ Isolate* isolate,
256+ Local<FixedArray> raw_attributes,
257+ const int elements_per_attribute) {
258+ CHECK_EQ (raw_attributes->Length () % elements_per_attribute, 0 );
255259 Local<Object> attributes =
256260 Object::New (isolate, v8::Null (env->isolate ()), nullptr , nullptr , 0 );
257- for (int i = 0 ; i < raw_attributes->Length (); i += 3 ) {
261+ for (int i = 0 ; i < raw_attributes->Length (); i += elements_per_attribute ) {
258262 attributes
259263 ->Set (env->context (),
260264 raw_attributes->Get (env->context (), i).As <String>(),
@@ -300,7 +304,7 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
300304
301305 Local<FixedArray> raw_attributes = module_request->GetImportAssertions ();
302306 Local<Object> attributes =
303- createImportAttributesContainer (env, isolate, raw_attributes);
307+ createImportAttributesContainer (env, isolate, raw_attributes, 3 );
304308
305309 Local<Value> argv[] = {
306310 specifier,
@@ -603,7 +607,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
603607 }
604608
605609 Local<Object> attributes =
606- createImportAttributesContainer (env, isolate, import_attributes);
610+ createImportAttributesContainer (env, isolate, import_attributes, 2 );
607611
608612 Local<Value> import_args[] = {
609613 object,
0 commit comments