Skip to content
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

Fixed issue with module state when extending the module Store #3618

Merged
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added italian translations - @lorenaramonda (3076)
- Route Manager Queue for adding routes efficiently and with an optional priority - @grimasod (#3540)
- Added tests for cart module actions - @andrzejewsky (#3023)
- Fixed a problem with type changes in the state when extending a store - @resubaka (#3618)

### Fixed

Expand Down
7 changes: 6 additions & 1 deletion core/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,13 @@ export function extendStore (moduleName: string | string[], module: any) {
for (let key in source) {
if (Array.isArray(source[key])) {
object[key] = merge([], source[key])
} else if (typeof source[key] === 'object') {
} else if (source[key] === null && !object[key]) {
object[key] = null
} else if (typeof source[key] === 'object' && Object.keys(source[key]).length > 0) {
object[key] = merge(object[key], source[key])
} else if (typeof source[key] === 'object' && object === null) {
object = {}
object[key] = source[key]
} else {
object[key] = source[key]
}
Expand Down