diff --git a/ecmascript/ecma_module.cpp b/ecmascript/ecma_module.cpp index 8a1a7c1e41c6a96f027c8561ad3ecf721bf7014a..260d8397da658c734b10c6d4be3a8a29e7c5c5e4 100644 --- a/ecmascript/ecma_module.cpp +++ b/ecmascript/ecma_module.cpp @@ -51,12 +51,17 @@ void EcmaModule::AddItem(const JSThread *thread, JSHandle module, JS } } -void EcmaModule::RemoveItem(const JSThread *thread, JSHandle itemName) +void EcmaModule::RemoveItem(const JSThread *thread, JSHandle module, JSHandle itemName) { - JSHandle moduleItems(thread, NameDictionary::Cast(GetNameDictionary().GetTaggedObject())); + JSHandle data(thread, module->GetNameDictionary()); + if (data->IsUndefined()) { + return; + } + JSHandle moduleItems(data); int entry = moduleItems->FindEntry(itemName.GetTaggedValue()); if (entry != -1) { - NameDictionary::Remove(thread, moduleItems, entry); // discard return + NameDictionary *newDict = NameDictionary::Remove(thread, moduleItems, entry); // discard return + module->SetNameDictionary(thread, JSTaggedValue(newDict)); } } diff --git a/ecmascript/ecma_module.h b/ecmascript/ecma_module.h index b6a053ab1f0863a85d000d6ad6f77065d1d30d89..ee744ac8d51d252c6748823ba2ae984e992d91fc 100644 --- a/ecmascript/ecma_module.h +++ b/ecmascript/ecma_module.h @@ -36,7 +36,7 @@ public: static void AddItem(const JSThread *thread, JSHandle module, JSHandle itemName, JSHandle itemValue); - void RemoveItem(const JSThread *thread, JSHandle itemName); + static void RemoveItem(const JSThread *thread, JSHandle module, JSHandle itemName); void DebugPrint(const JSThread *thread, const CString &caller);