@@ -251,10 +251,14 @@ void ModuleWrap::New(const FunctionCallbackInfo<Value>& args) {
251
251
}
252
252
253
253
static 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 );
255
259
Local<Object> attributes =
256
260
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 ) {
258
262
attributes
259
263
->Set (env->context (),
260
264
raw_attributes->Get (env->context (), i).As <String>(),
@@ -300,7 +304,7 @@ void ModuleWrap::Link(const FunctionCallbackInfo<Value>& args) {
300
304
301
305
Local<FixedArray> raw_attributes = module_request->GetImportAssertions ();
302
306
Local<Object> attributes =
303
- createImportAttributesContainer (env, isolate, raw_attributes);
307
+ createImportAttributesContainer (env, isolate, raw_attributes, 3 );
304
308
305
309
Local<Value> argv[] = {
306
310
specifier,
@@ -603,7 +607,7 @@ static MaybeLocal<Promise> ImportModuleDynamically(
603
607
}
604
608
605
609
Local<Object> attributes =
606
- createImportAttributesContainer (env, isolate, import_attributes);
610
+ createImportAttributesContainer (env, isolate, import_attributes, 2 );
607
611
608
612
Local<Value> import_args[] = {
609
613
object,
0 commit comments