mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Fix overwritten of non-object in CONFIG (#279)
This commit is contained in:
parent
0d84de6513
commit
f03b7ce306
@ -36,20 +36,31 @@ if (!window.NexT) window.NexT = {};
|
||||
existing = variableConfig[name];
|
||||
}
|
||||
|
||||
let override = overrideConfig[name];
|
||||
if (override === undefined && typeof existing === 'object') {
|
||||
override = {};
|
||||
overrideConfig[name] = override;
|
||||
// For unset override and mixable existing
|
||||
if (!(name in overrideConfig) && typeof existing === 'object') {
|
||||
// Get ready to mix.
|
||||
overrideConfig[name] = {};
|
||||
}
|
||||
|
||||
if (typeof override === 'object') {
|
||||
return new Proxy({...existing, ...override}, {
|
||||
set(target, prop, value) {
|
||||
override[prop] = value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (name in overrideConfig) {
|
||||
const override = overrideConfig[name];
|
||||
|
||||
// When mixable
|
||||
if (typeof override === 'object' && typeof existing === 'object') {
|
||||
// Mix, proxy changes to the override.
|
||||
return new Proxy({...existing, ...override}, {
|
||||
set(target, prop, value) {
|
||||
target[prop] = value;
|
||||
override[prop] = value;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return override;
|
||||
}
|
||||
|
||||
// Only when not mixable and override hasn't been set.
|
||||
return existing;
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user