@@ -250,10 +250,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
250250}
251251
252252static 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 );
254258 Local<Object> attributes =
255259 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 ) {
257261 attributes
258262 ->Set (env->context (),
259263 raw_attributes->Get (env->context (), i).As <String>(),
@@ -299,7 +303,7 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
299303
300304 Local<FixedArray> raw_attributes = module_request->GetImportAssertions ();
301305 Local<Object> attributes =
302- createImportAttributesContainer (env, isolate, raw_attributes);
306+ createImportAttributesContainer (env, isolate, raw_attributes, 3 );
303307
304308 Local<Value> argv[] = {
305309 specifier,
@@ -583,7 +587,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
583587 options->Get (context, HostDefinedOptions::kID ).As <Symbol>();
584588
585589 Local<Object> attributes =
586- createImportAttributesContainer (env, isolate, import_attributes);
590+ createImportAttributesContainer (env, isolate, import_attributes, 2 );
587591
588592 Local<Value> import_args[] = {
589593 id,
0 commit comments