diff --git a/core/misc/states.es6.js b/core/misc/states.es6.js index b47b90de57..6b3155e584 100644 --- a/core/misc/states.es6.js +++ b/core/misc/states.es6.js @@ -120,38 +120,30 @@ * dependee's compliance status. */ initializeDependee(selector, dependeeStates) { - let state; - const self = this; - - function stateEventHandler(e) { - self.update(e.data.selector, e.data.state, e.value); - } - // Cache for the states of this dependee. this.values[selector] = {}; - // eslint-disable-next-line no-restricted-syntax - for (const i in dependeeStates) { - if (dependeeStates.hasOwnProperty(i)) { - state = dependeeStates[i]; - // Make sure we're not initializing this selector/state combination - // twice. - if ($.inArray(state, dependeeStates) === -1) { - continue; - } + Object.keys(dependeeStates).forEach((i) => { + let state = dependeeStates[i]; + // Make sure we're not initializing this selector/state combination + // twice. + if ($.inArray(state, dependeeStates) === -1) { + return; + } - state = states.State.sanitize(state); + state = states.State.sanitize(state); - // Initialize the value of this state. - this.values[selector][state.name] = null; + // Initialize the value of this state. + this.values[selector][state.name] = null; - // Monitor state changes of the specified state for this dependee. - $(selector).on(`state:${state}`, { selector, state }, stateEventHandler); + // Monitor state changes of the specified state for this dependee. + $(selector).on(`state:${state}`, { selector, state }, (e) => { + this.update(e.data.selector, e.data.state, e.value); + }); - // Make sure the event we just bound ourselves to is actually fired. - new states.Trigger({ selector, state }); - } - } + // Make sure the event we just bound ourselves to is actually fired. + new states.Trigger({ selector, state }); + }); }, /** diff --git a/core/misc/states.js b/core/misc/states.js index 4fd2052a43..4c09e6967a 100644 --- a/core/misc/states.js +++ b/core/misc/states.js @@ -63,32 +63,27 @@ states.Dependent.prototype = { initializeDependee: function initializeDependee(selector, dependeeStates) { - var state = void 0; - var self = this; - - function stateEventHandler(e) { - self.update(e.data.selector, e.data.state, e.value); - } + var _this2 = this; this.values[selector] = {}; - for (var i in dependeeStates) { - if (dependeeStates.hasOwnProperty(i)) { - state = dependeeStates[i]; + Object.keys(dependeeStates).forEach(function (i) { + var state = dependeeStates[i]; - if ($.inArray(state, dependeeStates) === -1) { - continue; - } + if ($.inArray(state, dependeeStates) === -1) { + return; + } - state = states.State.sanitize(state); + state = states.State.sanitize(state); - this.values[selector][state.name] = null; + _this2.values[selector][state.name] = null; - $(selector).on('state:' + state, { selector: selector, state: state }, stateEventHandler); + $(selector).on('state:' + state, { selector: selector, state: state }, function (e) { + _this2.update(e.data.selector, e.data.state, e.value); + }); - new states.Trigger({ selector: selector, state: state }); - } - } + new states.Trigger({ selector: selector, state: state }); + }); }, compare: function compare(reference, selector, state) { var value = this.values[selector][state.name]; @@ -188,7 +183,7 @@ states.Trigger.prototype = { initialize: function initialize() { - var _this2 = this; + var _this3 = this; var trigger = states.Trigger.states[this.state]; @@ -196,7 +191,7 @@ trigger.call(window, this.element); } else { Object.keys(trigger || {}).forEach(function (event) { - _this2.defaultTrigger(event, trigger[event]); + _this3.defaultTrigger(event, trigger[event]); }); } diff --git a/core/modules/color/color.es6.js b/core/modules/color/color.es6.js index c4f923a02d..42c032f9ad 100644 --- a/core/modules/color/color.es6.js +++ b/core/modules/color/color.es6.js @@ -14,9 +14,6 @@ */ Drupal.behaviors.color = { attach(context, settings) { - let i; - let j; - let colors; // This behavior attaches by ID, so is only valid once on a page. const form = $(context).find('#system-theme-settings .color-form').once('color'); if (form.length === 0) { @@ -53,7 +50,7 @@ // Each gradient line should have a height (or width for horizontal // gradients) of 10px (because we divided the height/width by 10 // above). - for (j = 0; j < (settings.gradients[i].direction === 'vertical' ? height[i] : width[i]); ++j) { + for (let j = 0; j < (settings.gradients[i].direction === 'vertical' ? height[i] : width[i]); ++j) { gradient.append('
'); } }); @@ -64,7 +61,7 @@ const colorScheme = this.options[this.selectedIndex].value; if (colorScheme !== '' && schemes[colorScheme]) { // Get colors of active scheme. - colors = schemes[colorScheme]; + const colors = schemes[colorScheme]; Object.keys(colors || {}).forEach((fieldName) => { callback($(`#edit-palette-${fieldName}`), colors[fieldName], false, true); }); @@ -154,6 +151,8 @@ */ function callback(input, color, propagate, colorScheme) { let matched; + let i; + let j; // Set background/foreground colors. $(input).css({ backgroundColor: color, diff --git a/core/modules/color/color.js b/core/modules/color/color.js index 5cc0b9be12..dc25998740 100644 --- a/core/modules/color/color.js +++ b/core/modules/color/color.js @@ -8,10 +8,6 @@ (function ($, Drupal) { Drupal.behaviors.color = { attach: function attach(context, settings) { - var i = void 0; - var j = void 0; - var colors = void 0; - var form = $(context).find('#system-theme-settings .color-form').once('color'); if (form.length === 0) { return; @@ -40,7 +36,7 @@ width.push(parseInt(gradient.css('width'), 10) / 10); - for (j = 0; j < (settings.gradients[i].direction === 'vertical' ? height[i] : width[i]); ++j) { + for (var j = 0; j < (settings.gradients[i].direction === 'vertical' ? height[i] : width[i]); ++j) { gradient.append('
'); } }); @@ -49,7 +45,7 @@ var schemes = settings.color.schemes; var colorScheme = this.options[this.selectedIndex].value; if (colorScheme !== '' && schemes[colorScheme]) { - colors = schemes[colorScheme]; + var colors = schemes[colorScheme]; Object.keys(colors || {}).forEach(function (fieldName) { callback($('#edit-palette-' + fieldName), colors[fieldName], false, true); }); @@ -95,6 +91,8 @@ function callback(input, color, propagate, colorScheme) { var matched = void 0; + var i = void 0; + var j = void 0; $(input).css({ backgroundColor: color, diff --git a/core/modules/editor/js/editor.admin.es6.js b/core/modules/editor/js/editor.admin.es6.js index a9c040c72e..a31048ea70 100644 --- a/core/modules/editor/js/editor.admin.es6.js +++ b/core/modules/editor/js/editor.admin.es6.js @@ -567,17 +567,14 @@ // If any filter's current status forbids the editor feature, return // false. Drupal.filterConfiguration.update(); - // eslint-disable-next-line no-restricted-syntax - for (const filterID in Drupal.filterConfiguration.statuses) { - if (Drupal.filterConfiguration.statuses.hasOwnProperty(filterID)) { + const disallowedFeature = Object.keys(Drupal.filterConfiguration.statuses) + // We use some to do an early return when filterStatusAllowsFeature + // returns false. + .some((filterID) => { const filterStatus = Drupal.filterConfiguration.statuses[filterID]; - if (!(filterStatusAllowsFeature(filterStatus, feature))) { - return false; - } - } - } - - return true; + return !filterStatusAllowsFeature(filterStatus, feature); + }); + return !disallowedFeature; }, }; diff --git a/core/modules/editor/js/editor.admin.js b/core/modules/editor/js/editor.admin.js index 9cec9ada6a..1fb2a710a8 100644 --- a/core/modules/editor/js/editor.admin.js +++ b/core/modules/editor/js/editor.admin.js @@ -256,17 +256,11 @@ } Drupal.filterConfiguration.update(); - - for (var filterID in Drupal.filterConfiguration.statuses) { - if (Drupal.filterConfiguration.statuses.hasOwnProperty(filterID)) { - var filterStatus = Drupal.filterConfiguration.statuses[filterID]; - if (!filterStatusAllowsFeature(filterStatus, feature)) { - return false; - } - } - } - - return true; + var disallowedFeature = Object.keys(Drupal.filterConfiguration.statuses).some(function (filterID) { + var filterStatus = Drupal.filterConfiguration.statuses[filterID]; + return !filterStatusAllowsFeature(filterStatus, feature); + }); + return !disallowedFeature; } };