Loading core/modules/big_pipe/js/big_pipe.commands.js +11 −10 Original line number Diff line number Diff line Loading @@ -54,17 +54,14 @@ * An optional selector string. */ insert({ data, method, selector }) { const target = htmx.find(selector); const targets = htmx.findAll(selector); // In rare circumstances, the target may not be found, such as if // the target is in a noscript element. if (target === null) { // In rare circumstances, the targets may not be found, such as if // the targets are in noscript elements. if (!targets || !targets.length) { return; } // Detach behaviors. htmx.trigger(target, 'htmx:drupal:unload'); // Map jQuery manipulation methods to the DOM equivalent. const styleMap = { replaceWith: 'outerHTML', Loading @@ -74,11 +71,15 @@ append: 'beforeend', after: 'afterend', }; targets.forEach((target) => { // Detach behaviors. htmx.trigger(target, 'htmx:drupal:unload'); // Make the actual swap and initialize everything. htmx.swap(target, data, { swapStyle: styleMap[method] || 'outerHTML', }); }); }, /** Loading core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php +1 −1 Original line number Diff line number Diff line Loading @@ -231,7 +231,7 @@ public static function counter() { $count++; return [ '#markup' => BigPipeMarkup::create("<p>The count is $count.</p>"), '#markup' => BigPipeMarkup::create("<p class=\"multiple-occurrence-instance\">The count is $count.</p>"), '#cache' => ['max-age' => 0], ]; } Loading core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -209,4 +209,17 @@ protected function doInlineScriptTest(): void { $assert_session->elementExists('css', 'div.container-after'); } /** * Tests that all occurrences of the same placeholder are replaced. */ public function testMultipleOccurrences(): void { \Drupal::service('module_installer')->install(['big_pipe_test']); $user = $this->drupalCreateUser(); $this->drupalLogin($user); $assert_session = $this->assertSession(); $this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence')); $this->assertNotNull($assert_session->waitForElement('css', 'script[data-big-pipe-event="stop"]')); $assert_session->elementsCount('css', 'p.multiple-occurrence-instance', 3); } } Loading
core/modules/big_pipe/js/big_pipe.commands.js +11 −10 Original line number Diff line number Diff line Loading @@ -54,17 +54,14 @@ * An optional selector string. */ insert({ data, method, selector }) { const target = htmx.find(selector); const targets = htmx.findAll(selector); // In rare circumstances, the target may not be found, such as if // the target is in a noscript element. if (target === null) { // In rare circumstances, the targets may not be found, such as if // the targets are in noscript elements. if (!targets || !targets.length) { return; } // Detach behaviors. htmx.trigger(target, 'htmx:drupal:unload'); // Map jQuery manipulation methods to the DOM equivalent. const styleMap = { replaceWith: 'outerHTML', Loading @@ -74,11 +71,15 @@ append: 'beforeend', after: 'afterend', }; targets.forEach((target) => { // Detach behaviors. htmx.trigger(target, 'htmx:drupal:unload'); // Make the actual swap and initialize everything. htmx.swap(target, data, { swapStyle: styleMap[method] || 'outerHTML', }); }); }, /** Loading
core/modules/big_pipe/tests/modules/big_pipe_test/src/BigPipeTestController.php +1 −1 Original line number Diff line number Diff line Loading @@ -231,7 +231,7 @@ public static function counter() { $count++; return [ '#markup' => BigPipeMarkup::create("<p>The count is $count.</p>"), '#markup' => BigPipeMarkup::create("<p class=\"multiple-occurrence-instance\">The count is $count.</p>"), '#cache' => ['max-age' => 0], ]; } Loading
core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -209,4 +209,17 @@ protected function doInlineScriptTest(): void { $assert_session->elementExists('css', 'div.container-after'); } /** * Tests that all occurrences of the same placeholder are replaced. */ public function testMultipleOccurrences(): void { \Drupal::service('module_installer')->install(['big_pipe_test']); $user = $this->drupalCreateUser(); $this->drupalLogin($user); $assert_session = $this->assertSession(); $this->drupalGet(Url::fromRoute('big_pipe_test_multi_occurrence')); $this->assertNotNull($assert_session->waitForElement('css', 'script[data-big-pipe-event="stop"]')); $assert_session->elementsCount('css', 'p.multiple-occurrence-instance', 3); } }