Skip to content

Commit 13343ad

Browse files
DeepMerge failed to merge instantiated objects
I have observed that the DeepMerge library fails to correctly merge instantiated objects, which is causing issues with the Stage object context option. The canvas option value is being reassinged after DeepMerge but the context option is not being handled properly. To resolve this issue, I have introduced a new option called 'isMergeableObject' in the DeepMerge library. This option copies the whole instantiated object, instead of just copying its properties. This allows the proper merging of instantiated objects and resolves both the canvas and context options issues with DeepMerge. Signed-off-by: suresh-gangumalla <[email protected]>
1 parent 546c85e commit 13343ad

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

package-lock.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@metrological/sdk": "^1.0.0",
3030
"@michieljs/execute-as-promise": "^1.0.0",
3131
"deepmerge": "^4.2.2",
32+
"is-plain-object": "^5.0.0",
3233
"localcookies": "^2.0.0",
3334
"shelljs": "^0.8.5",
3435
"url-polyfill": "^1.1.10",

src/Application/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import Accessibility from '../Accessibility'
2121
import Deepmerge from 'deepmerge'
22+
import { isPlainObject } from 'is-plain-object'
2223
import Lightning from '../Lightning'
2324
import Locale from '../Locale'
2425
import Metrics from '../Metrics'
@@ -99,11 +100,10 @@ export default function(App, appData, platformSettings) {
99100

100101
return class Application extends Lightning.Application {
101102
constructor(options) {
102-
const config = Deepmerge(defaultOptions, options)
103-
// Deepmerge breaks HTMLCanvasElement, so restore the passed in canvas.
104-
if (options.stage.canvas) {
105-
config.stage.canvas = options.stage.canvas
106-
}
103+
const config = Deepmerge(defaultOptions, options, {
104+
isMergeableObject: isPlainObject
105+
})
106+
107107
super(config)
108108
this.config = config
109109
}

0 commit comments

Comments
 (0)