mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-20 19:02:33 +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];
|
existing = variableConfig[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
let override = overrideConfig[name];
|
// For unset override and mixable existing
|
||||||
if (override === undefined && typeof existing === 'object') {
|
if (!(name in overrideConfig) && typeof existing === 'object') {
|
||||||
override = {};
|
// Get ready to mix.
|
||||||
overrideConfig[name] = override;
|
overrideConfig[name] = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof override === 'object') {
|
if (name in overrideConfig) {
|
||||||
return new Proxy({...existing, ...override}, {
|
const override = overrideConfig[name];
|
||||||
set(target, prop, value) {
|
|
||||||
override[prop] = value;
|
// When mixable
|
||||||
return true;
|
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;
|
return existing;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user