Skip to content

Commit f496197

Browse files
committed
#6937 component.Base: mergeConfig() => further polishing
1 parent 45f2bdf commit f496197

2 files changed

Lines changed: 6 additions & 19 deletions

File tree

src/Neo.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Neo = globalThis.Neo = Object.assign({
360360
if (strategy === 'shallow') {
361361
return {...defaultValue, ...instanceValue}
362362
} else if (strategy === 'deep') {
363-
return Neo.merge(Neo.clone(defaultValue, true), instanceValue);
363+
return Neo.merge(Neo.clone(defaultValue, true), instanceValue)
364364
} else if (typeof strategy === 'function') {
365365
return strategy(defaultValue, instanceValue)
366366
} else { // Default to 'replace' or if strategy is not recognized

src/component/Base.mjs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,28 +2036,15 @@ class Component extends Base {
20362036
* @returns {Object} config
20372037
*/
20382038
mergeConfig(...args) {
2039-
let me = this,
2040-
config = super.mergeConfig(...args),
2041-
2042-
// it should be possible to set custom configs for the vdom on instance level,
2043-
// however there will be already added attributes (e.g. id), so a merge seems to be the best strategy.
2044-
vdom = {...me._vdom || {}, ...config.vdom || {}};
2045-
2046-
// avoid any interference on prototype level
2047-
// does not clone existing Neo instances
2048-
me._vdom = Neo.clone(vdom, true, true);
2049-
2050-
if (config.style) {
2051-
// If we are passed an object, merge it with the class's own style
2052-
me.style = Neo.typeOf(config.style) === 'Object' ? {...config.style, ...me.constructor.config.style} : config.style
2053-
}
2039+
let config = super.mergeConfig(...args),
2040+
vdom = config.vdom || config._vdom || {};
20542041

2055-
me.wrapperStyle = Neo.clone(config.wrapperStyle, false);
2042+
// It should be possible to modify the vdom on instance level.
2043+
// Note that vdom is not a real config, but implemented via get() & set().
2044+
this._vdom = Neo.merge(Neo.clone(this._vdom, true) || {}, Neo.clone(vdom, true));
20562045

2057-
delete config.style;
20582046
delete config._vdom;
20592047
delete config.vdom;
2060-
delete config.wrapperStyle;
20612048

20622049
return config
20632050
}

0 commit comments

Comments
 (0)