Merge pull request #13892 from Snuffleupagus/Dict-merge-refactor-2
Move some validation, in `Dict.merge`, used during merging of sub-dictionaries (PR 13775 follow-up)
This commit is contained in:
commit
e9146b19e6
@ -197,8 +197,11 @@ class Dict {
|
|||||||
if (property === undefined) {
|
if (property === undefined) {
|
||||||
property = [];
|
property = [];
|
||||||
properties.set(key, property);
|
properties.set(key, property);
|
||||||
} else if (!mergeSubDicts) {
|
} else if (!mergeSubDicts || !(value instanceof Dict)) {
|
||||||
continue; // Ignore additional entries for a "shallow" merge.
|
// Ignore additional entries, if either:
|
||||||
|
// - This is a "shallow" merge, where only the first element matters.
|
||||||
|
// - The value is *not* a `Dict`, since other types cannot be merged.
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
property.push(value);
|
property.push(value);
|
||||||
}
|
}
|
||||||
@ -211,9 +214,6 @@ class Dict {
|
|||||||
const subDict = new Dict(xref);
|
const subDict = new Dict(xref);
|
||||||
|
|
||||||
for (const dict of values) {
|
for (const dict of values) {
|
||||||
if (!(dict instanceof Dict)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (const [key, value] of Object.entries(dict._map)) {
|
for (const [key, value] of Object.entries(dict._map)) {
|
||||||
if (subDict._map[key] === undefined) {
|
if (subDict._map[key] === undefined) {
|
||||||
subDict._map[key] = value;
|
subDict._map[key] = value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user