export non-enumerable values

This commit is contained in:
Dylan Conway
2023-08-31 16:20:26 -07:00
parent bd7262f037
commit 4d944773f0
2 changed files with 79 additions and 4 deletions

View File

@@ -556,7 +556,7 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject,
if (canPerformFastEnumeration(structure)) {
exports->structure()->forEachProperty(vm, [&](const PropertyTableEntry& entry) -> bool {
auto key = entry.key();
if (key->isSymbol() || entry.attributes() & PropertyAttribute::DontEnum || key == esModuleMarker)
if (key->isSymbol() || entry.attributes() & PropertyAttribute::Accessor || entry.attributes() & PropertyAttribute::CustomAccessor || key == esModuleMarker)
return true;
needsToAssignDefault = needsToAssignDefault && key != vm.propertyNames->defaultKeyword;
@@ -568,7 +568,7 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject,
});
} else {
JSC::PropertyNameArray properties(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude);
exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Exclude);
exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Include);
if (catchScope.exception()) {
catchScope.clearExceptionExceptTermination();
return;
@@ -586,6 +586,9 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject,
if (!exports->getPropertySlot(globalObject, property, slot))
continue;
if (slot.isAccessor() || slot.isUnset())
continue;
exportNames.append(property);
JSValue getterResult = slot.getValue(globalObject, property);
@@ -606,7 +609,7 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject,
} else if (canPerformFastEnumeration(structure)) {
exports->structure()->forEachProperty(vm, [&](const PropertyTableEntry& entry) -> bool {
auto key = entry.key();
if (key->isSymbol() || entry.attributes() & PropertyAttribute::DontEnum || key == vm.propertyNames->defaultKeyword)
if (key->isSymbol() || key == vm.propertyNames->defaultKeyword || entry.attributes() & PropertyAttribute::Accessor || entry.attributes() & PropertyAttribute::CustomAccessor)
return true;
JSValue value = exports->getDirect(entry.offset());
@@ -617,7 +620,7 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject,
});
} else {
JSC::PropertyNameArray properties(vm, JSC::PropertyNameMode::Strings, JSC::PrivateSymbolMode::Exclude);
exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Exclude);
exports->methodTable()->getOwnPropertyNames(exports, globalObject, properties, DontEnumPropertiesMode::Include);
if (catchScope.exception()) {
catchScope.clearExceptionExceptTermination();
return;
@@ -635,6 +638,9 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject,
if (!exports->getPropertySlot(globalObject, property, slot))
continue;
if (slot.isAccessor() || slot.isUnset())
continue;
exportNames.append(property);
JSValue getterResult = slot.getValue(globalObject, property);