7417 _this2.update(e.data.selector, e.data.state, e.value);
7418 }
7419 );
7420 new states.Trigger({ 7421 selector: selector, 7422 state: state, 7423 }); 7424 });
7425 },
7426 compare: function compare(reference, selector, state) {
7345 var _loop = function _loop(i) {
7346 var config = JSON.parse($states[i].getAttribute("data-drupal-states"));
7347 Object.keys(config || {}).forEach(function (state) {
7348 new states.Dependent({ 7349 element: $($states[i]), 7350 state: states.State.sanitize(state), 7351 constraints: config[state], 7352 }); 7353 });
7354 };
7355
7462 var _loop = function _loop(i) {
7463 var config = JSON.parse($states[i].getAttribute("data-drupal-states"));
7464 Object.keys(config || {}).forEach(function (state) {
7465 new states.Dependent({ 7466 element: $($states[i]), 7467 state: states.State.sanitize(state), 7468 constraints: config[state], 7469 }); 7470 });
7471 };
7472
7534 _this2.update(e.data.selector, e.data.state, e.value);
7535 }
7536 );
7537 new states.Trigger({ 7538 selector: selector, 7539 state: state, 7540 }); 7541 });
7542 },
7543 compare: function compare(reference, selector, state) {
7914 _this2.update(e.data.selector, e.data.state, e.value);
7915 }
7916 );
7917 new states.Trigger({ 7918 selector: selector, 7919 state: state, 7920 }); 7921 });
7922 },
7923 compare: function compare(reference, selector, state) {
Class constructors being invoked and then dropped immediately is an anti-pattern and should be avoided.
Objects instantiated with new
should always be useful in some way (passed as a function argument, stored in a variable for later use, etc).
If the object is instantiated only to invoke some side effect in the constructor, then the side effect should be refactored out into it's own function.
new Foo()
const myFoo = new Foo()