Skip to content

Move some validation, in Dict.merge, used during merging of sub-dictionaries (PR 13775 follow-up) #13892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/core/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,11 @@ class Dict {
if (property === undefined) {
property = [];
properties.set(key, property);
} else if (!mergeSubDicts) {
continue; // Ignore additional entries for a "shallow" merge.
} else if (!mergeSubDicts || !(value instanceof Dict)) {
// 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);
}
Expand All @@ -211,9 +214,6 @@ class Dict {
const subDict = new Dict(xref);

for (const dict of values) {
if (!(dict instanceof Dict)) {
continue;
}
for (const [key, value] of Object.entries(dict._map)) {
if (subDict._map[key] === undefined) {
subDict._map[key] = value;
Expand Down