Skip to content

Commit dd7c72f

Browse files
committed
Another try on reducing the complexity
1 parent a37cfdc commit dd7c72f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/helpers/helpers.config.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,8 @@ function createSubResolver(parentScopes, prop, value) {
157157
const set = new Set([value]);
158158
const {keys, includeParents} = _resolveSubKeys(parentScopes, prop, value);
159159
for (const key of keys) {
160-
for (const item of parentScopes) {
161-
const scope = resolveObjectKey(item, key);
162-
if (scope) {
163-
set.add(scope);
164-
} else if (key !== prop && scope === false) {
165-
// If any of the fallback scopes is explicitly false, return false
166-
// For example, options.hover falls back to options.interaction, when
167-
// options.interaction is false, options.hover will also resolve as false.
168-
return false;
169-
}
160+
if (addScopes(set, prop, key, parentScopes) === false) {
161+
return false;
170162
}
171163
}
172164
if (includeParents) {
@@ -175,6 +167,20 @@ function createSubResolver(parentScopes, prop, value) {
175167
return _createResolver([...set]);
176168
}
177169

170+
function addScopes(set, prop, key, parentScopes) {
171+
for (const item of parentScopes) {
172+
const scope = resolveObjectKey(item, key);
173+
if (scope) {
174+
set.add(scope);
175+
} else if (key !== prop && scope === false) {
176+
// If any of the fallback scopes is explicitly false, return false
177+
// For example, options.hover falls back to options.interaction, when
178+
// options.interaction is false, options.hover will also resolve as false.
179+
return false;
180+
}
181+
}
182+
}
183+
178184
function _resolveSubKeys(parentScopes, prop, value) {
179185
const fallback = _resolve('_fallback', parentScopes.map(scope => scope[prop] || scope));
180186
const keys = [prop];

0 commit comments

Comments
 (0)