From 0f780e302b3055192486f0da1ab8aebb79b324ba Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 20 Jan 2025 06:20:07 +0100 Subject: [PATCH] fix(midi-components): revert deepMerge to avoid TypeError Fixes #14197 --- res/controllers/common-controller-scripts.js | 52 -------------------- res/controllers/midi-components-0.0.js | 2 +- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index 4199439026e..5045a28f461 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -140,58 +140,6 @@ var colorCodeToObject = function(colorCode) { var script = function() { }; -/** - * Discriminates whether an object was created using the `{}` synthax. - * - * Returns true when was an object was created using the `{}` synthax. - * False if the object is an instance of a class like Date or Proxy or an Array. - * - * isSimpleObject({}) // true - * isSimpleObject(null) // false - * isSimpleObject(undefined) // false - * isSimpleObject(new Date) // false - * isSimpleObject(new (class {})()) // false - * @param {any} obj Object to test - * @returns {boolean} true if obj was created using the `{}` or `new Object()` synthax, false otherwise - */ -const isSimpleObject = function(obj) { - return obj !== null && typeof obj === "object" && obj.constructor.name === "Object"; -}; - -script.isSimpleObject = isSimpleObject; - -/** - * Deeply merges 2 objects (Arrays and Objects only, not Map for instance). - * @param target {object | Array} Object to merge source into - * @param source {object | Array} Object to merge into source - */ -const deepMerge = function(target, source) { - if (target === source || target === undefined || target === null || source === undefined || source === null) { - return; - } - - if (Array.isArray(target) && Array.isArray(source)) { - const objTarget = target.reduce((acc, val, idx) => Object.assign(acc, {[idx]: val}), {}); - const objSource = source.reduce((acc, val, idx) => Object.assign(acc, {[idx]: val}), {}); - deepMerge(objTarget, objSource); - target.length = 0; - target.push(...Object.values(objTarget)); - } else if (isSimpleObject(target) && isSimpleObject(source)) { - Object.keys(source).forEach(key => { - if ( - Array.isArray(target[key]) && Array.isArray(source[key]) || - isSimpleObject(target[key]) && isSimpleObject(source[key]) - ) { - deepMerge(target[key], source[key]); - } else if (source[key] !== undefined && source[key] !== null) { - Object.assign(target, {[key]: source[key]}); - } - }); - } -}; - -script.deepMerge = deepMerge; - // ----------------- Mapping constants --------------------- // Library column value, which can be used to interact with the CO for "[Library] sort_column" diff --git a/res/controllers/midi-components-0.0.js b/res/controllers/midi-components-0.0.js index 225e5c6e083..9e1fbdc9fac 100644 --- a/res/controllers/midi-components-0.0.js +++ b/res/controllers/midi-components-0.0.js @@ -660,7 +660,7 @@ }); } - script.deepMerge(this, newLayer); + Object.assign(this, newLayer); if (reconnectComponents === true) { this.forEachComponent(function(component) {