fix(Object): Prevent removed wildcard object properties persisting when replacing/resetting

This commit is contained in:
Kai Moseley 2017-09-01 11:44:22 +01:00
parent c3d80b4223
commit c0429059e8
2 changed files with 3021 additions and 880 deletions

3888
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -118,16 +118,13 @@ export function createReducer(objectStructure: StructureType, behaviors: ShapeRe
if (matchedBehaviors.length) { if (matchedBehaviors.length) {
//Sanitize the payload using the reducer shape, then apply the sanitized //Sanitize the payload using the reducer shape, then apply the sanitized
//payload to the state using the behavior linked to this action type. //payload to the state using the behavior linked to this action type.
return reduce((interimState, matchedBehavior) => ({ return reduce((interimState, matchedBehavior) => behaviors[matchedBehavior.type].reducer(
...interimState,
...behaviors[matchedBehavior.type].reducer(
interimState, interimState,
behaviors[matchedBehavior.type].validate behaviors[matchedBehavior.type].validate
? validateShape(objectStructure, matchedBehavior.payload) ? validateShape(objectStructure, matchedBehavior.payload)
: matchedBehavior.payload, : matchedBehavior.payload,
initialState initialState,
) ), state)(matchedBehaviors);
}), state)(matchedBehaviors);
} }
return state; return state;