7428 _this2.update(e.data.selector, e.data.state, e.value);
7429 },
7430 );
7431 new states.Trigger({ 7432 selector: selector, 7433 state: state, 7434 }); 7435 });
7436 },
7437 compare: function compare(reference, selector, state) {
7356 var _loop = function _loop(i) {
7357 var config = JSON.parse($states[i].getAttribute("data-drupal-states"));
7358 Object.keys(config || {}).forEach(function (state) {
7359 new states.Dependent({ 7360 element: $($states[i]), 7361 state: states.State.sanitize(state), 7362 constraints: config[state], 7363 }); 7364 });
7365 };
7366
7545 _this2.update(e.data.selector, e.data.state, e.value);
7546 },
7547 );
7548 new states.Trigger({ 7549 selector: selector, 7550 state: state, 7551 }); 7552 });
7553 },
7554 compare: function compare(reference, selector, state) {
7473 var _loop = function _loop(i) {
7474 var config = JSON.parse($states[i].getAttribute("data-drupal-states"));
7475 Object.keys(config || {}).forEach(function (state) {
7476 new states.Dependent({ 7477 element: $($states[i]), 7478 state: states.State.sanitize(state), 7479 constraints: config[state], 7480 }); 7481 });
7482 };
7483
7925 _this2.update(e.data.selector, e.data.state, e.value);
7926 },
7927 );
7928 new states.Trigger({ 7929 selector: selector, 7930 state: state, 7931 }); 7932 });
7933 },
7934 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()