Use proper access methods in Dict.merge, rather than modifying the _map field manually

This commit is contained in:
Jonas Jenwald 2026-03-17 12:00:35 +01:00
parent bda7456724
commit 6c6bb19324

View File

@ -236,7 +236,7 @@ class Dict {
if (!(dict instanceof Dict)) {
continue;
}
for (const [key, value] of dict._map) {
for (const [key, value] of dict.getRawEntries()) {
let property = properties.get(key);
if (property === undefined) {
property = [];
@ -252,20 +252,18 @@ class Dict {
}
for (const [name, values] of properties) {
if (values.length === 1 || !(values[0] instanceof Dict)) {
mergedDict._map.set(name, values[0]);
mergedDict.set(name, values[0]);
continue;
}
const subDict = new Dict(xref);
for (const dict of values) {
for (const [key, value] of dict._map) {
if (!subDict._map.has(key)) {
subDict._map.set(key, value);
}
for (const [key, value] of dict.getRawEntries()) {
subDict.setIfNotExists(key, value);
}
}
if (subDict.size > 0) {
mergedDict._map.set(name, subDict);
mergedDict.set(name, subDict);
}
}
properties.clear();