From 377180847fa99f3e7ccba6e0f59e29267a84edc0 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Fri, 26 Jan 2024 15:49:30 +0000
Subject: [PATCH] =?UTF-8?q?Revert=20"Issue=20#3347144=20by=20dgtlmoon,=20m?=
 =?UTF-8?q?strelan,=20Evaldas=20U=C5=BEkuras,=20bkosborne,=20FeyP,=20pirvu?=
 =?UTF-8?q?doru:=20Form=20API=20#states=20property/states=20should=20use?=
 =?UTF-8?q?=20.once()=20to=20apply=20its=20rules=20(Can=20cause=20failures?=
 =?UTF-8?q?=20with=20BigPipe=20and=20possibly=20other=20situations)"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit d6b6ad8fd6b479d5721cf0e4cddba04a1dbc3d0d.
---
 core/misc/states.js                                   | 11 +++++------
 .../Core/Form/JavascriptStatesTest.php                |  2 +-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/core/misc/states.js b/core/misc/states.js
index 7399aacb38a1..218b89268884 100644
--- a/core/misc/states.js
+++ b/core/misc/states.js
@@ -93,16 +93,15 @@
    */
   Drupal.behaviors.states = {
     attach(context, settings) {
-      const elements = once('states', '[data-drupal-states]', context);
-      const il = elements.length;
-
+      const $states = $(context).find('[data-drupal-states]');
+      const il = $states.length;
       for (let i = 0; i < il; i++) {
         const config = JSON.parse(
-          elements[i].getAttribute('data-drupal-states'),
+          $states[i].getAttribute('data-drupal-states'),
         );
         Object.keys(config || {}).forEach((state) => {
           new states.Dependent({
-            element: $(elements[i]),
+            element: $($states[i]),
             state: states.State.sanitize(state),
             constraints: config[state],
           });
@@ -121,7 +120,7 @@
    *
    * @constructor Drupal.states.Dependent
    *
-   * @param {{state: Drupal.states.state, constraints: *, element: (*|jQuery|HTMLElement)}} args
+   * @param {object} args
    *   Object with the following keys (all of which are required)
    * @param {jQuery} args.element
    *   A jQuery object of the dependent element
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php
index 2624a15ce36c..ab7425a252d8 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Core/Form/JavascriptStatesTest.php
@@ -27,7 +27,7 @@ class JavascriptStatesTest extends WebDriverTestBase {
   /**
    * {@inheritdoc}
    */
-  protected static $modules = ['form_test', 'big_pipe'];
+  protected static $modules = ['form_test'];
 
   /**
    * {@inheritdoc}
-- 
GitLab