diff --git a/core/misc/states.es6.js b/core/misc/states.es6.js index d4be927b2f..80b133706b 100644 --- a/core/misc/states.es6.js +++ b/core/misc/states.es6.js @@ -261,13 +261,15 @@ // bogus, we don't want to end up with an infinite loop. else if ($.isPlainObject(constraints)) { // This constraint is an object (AND). - // Array.some returns early if any result returns true, aka. a constraint failed. - - const failedConstraint = Object.keys(constraints).some(n => ( - !ternary(result, this.checkConstraints(constraints[n], selector, n)) - )); - if (failedConstraint) { - return false; + const constraintsIds = Object.keys(constraints); + for (let i = 0; i < constraintsIds.length; i++) { + const n = constraintsIds[i]; + result = ternary(result, this.checkConstraints(constraints[n], selector, n)); + // False and anything else will evaluate to false, so return when + // any false condition is found. + if (result === false) { + return false; + } } } return result; diff --git a/core/misc/states.js b/core/misc/states.js index 559e4b37cd..098b44914f 100644 --- a/core/misc/states.js +++ b/core/misc/states.js @@ -118,8 +118,6 @@ } }, verifyConstraints: function verifyConstraints(constraints, selector) { - var _this3 = this; - var result = void 0; if ($.isArray(constraints)) { var hasXor = $.inArray('xor', constraints) === -1; @@ -135,12 +133,14 @@ } } } else if ($.isPlainObject(constraints)) { + var constraintsIds = Object.keys(constraints); + for (var _i = 0; _i < constraintsIds.length; _i++) { + var n = constraintsIds[_i]; + result = ternary(result, this.checkConstraints(constraints[n], selector, n)); - var failedConstraint = Object.keys(constraints).some(function (n) { - return !ternary(result, _this3.checkConstraints(constraints[n], selector, n)); - }); - if (failedConstraint) { - return false; + if (result === false) { + return false; + } } } return result; @@ -190,7 +190,7 @@ states.Trigger.prototype = { initialize: function initialize() { - var _this4 = this; + var _this3 = this; var trigger = states.Trigger.states[this.state]; @@ -198,7 +198,7 @@ trigger.call(window, this.element); } else { Object.keys(trigger).forEach(function (event) { - _this4.defaultTrigger(event, trigger[event]); + _this3.defaultTrigger(event, trigger[event]); }); } diff --git a/core/modules/editor/js/editor.admin.es6.js b/core/modules/editor/js/editor.admin.es6.js index 9c5b3d98ae..9eaff8164b 100644 --- a/core/modules/editor/js/editor.admin.es6.js +++ b/core/modules/editor/js/editor.admin.es6.js @@ -567,10 +567,13 @@ // If any filter's current status forbids the editor feature, return // false. Drupal.filterConfiguration.update(); - Object.keys(Drupal.filterConfiguration.statuses).some((filterID) => { + const disallowedFeature = Object.keys(Drupal.filterConfiguration.statuses).some((filterID) => { const filterStatus = Drupal.filterConfiguration.statuses[filterID]; return !filterStatusAllowsFeature(filterStatus, feature); }); + if (disallowedFeature) { + return false; + } return true; }, diff --git a/core/modules/editor/js/editor.admin.js b/core/modules/editor/js/editor.admin.js index 13151af491..cdb51cede9 100644 --- a/core/modules/editor/js/editor.admin.js +++ b/core/modules/editor/js/editor.admin.js @@ -256,10 +256,13 @@ } Drupal.filterConfiguration.update(); - Object.keys(Drupal.filterConfiguration.statuses).some(function (filterID) { + var disallowedFeature = Object.keys(Drupal.filterConfiguration.statuses).some(function (filterID) { var filterStatus = Drupal.filterConfiguration.statuses[filterID]; return !filterStatusAllowsFeature(filterStatus, feature); }); + if (disallowedFeature) { + return false; + } return true; }