Skip to content

Commit ca0621d

Browse files
committed
🐛 Fix settings proxy objects
1 parent a9b0840 commit ca0621d

File tree

2 files changed

+49
-2
lines changed

2 files changed

+49
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Fix `_modelInstance` cache when keys are not strings
44
* Fix certain settings not being applied if they're created after generating the main system setting object
5+
* Fix settings proxy objects
56

67
## 1.4.0-alpha.7 (2024-10-10)
78

lib/core/setting.js

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,15 +1734,61 @@ const MagicGroupValue = Function.inherits('Magic', 'Alchemy.Setting', function M
17341734
*/
17351735
MagicGroupValue.setMethod(function __get(key) {
17361736

1737-
let result = this[VALUE].get(key);
1737+
let result = this[key];
1738+
1739+
if (result != null) {
1740+
return result;
1741+
}
1742+
1743+
result = this[VALUE].get(key);
1744+
1745+
if (result == null) {
1746+
return this[VALUE][key];
1747+
}
17381748

17391749
if (!result) {
1740-
return;
1750+
return result;
17411751
}
17421752

17431753
if (result.is_group) {
17441754
return result.toProxyObject();
17451755
}
17461756

1757+
if (!result.get) {
1758+
return result;
1759+
}
1760+
17471761
return result.get();
1762+
});
1763+
1764+
/**
1765+
* The magic getter
1766+
*
1767+
* @author Jelle De Loecker <jelle@elevenways.be>
1768+
* @since 1.4.0
1769+
* @version 1.4.0
1770+
*
1771+
* @param {string} key
1772+
*/
1773+
MagicGroupValue.setMethod(function __ownKeys() {
1774+
return Object.keys(this[VALUE].toObject())
1775+
});
1776+
1777+
/**
1778+
* The magic getter
1779+
*
1780+
* @author Jelle De Loecker <jelle@elevenways.be>
1781+
* @since 1.4.0
1782+
* @version 1.4.0
1783+
*
1784+
* @param {string} key
1785+
*/
1786+
MagicGroupValue.setMethod(function __describe(key) {
1787+
let result = Object.getOwnPropertyDescriptor(this[VALUE], key);
1788+
1789+
if (result == null) {
1790+
result = Object.getOwnPropertyDescriptor(this, key);
1791+
}
1792+
1793+
return result;
17481794
});

0 commit comments

Comments
 (0)