Browse Source

Fix device codecs recursive merge of defaults (#237)

* Extract device data merging to own variable

* Make existing settings take precedence over defaults

Using lodash#mergeWith to take into account the fact that we are merging
down existing settings into defualts, in which case, when evaluated
values are arrays, the former should take precedence over the latter and
is then "assigned" rather than "merge".

* Assign overrides over existing settings to replace vs merge
4.3
Joris Tirado 6 years ago
committed by GitHub
parent
commit
d1996821ee
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      submodules/devices/devices.js

+ 8
- 1
submodules/devices/devices.js View File

@ -1031,11 +1031,18 @@ define(function(require) {
.mapValues('data')
.value()
},
mergedDevice = _.merge(
deviceData = _.mergeWith(
{},
deviceDefaults,
deviceDefaultsForType,
data.device,
function(dest, src) {
return _.every([dest, src], _.isArray) ? src : undefined;
}
),
mergedDevice = _.assign(
{},
deviceData,
deviceOverrides
);


Loading…
Cancel
Save