protected function SortableTestTrait::sortableAfter in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalJavascriptTests/SortableTestTrait.php \Drupal\FunctionalJavascriptTests\SortableTestTrait::sortableAfter()
- 9 core/tests/Drupal/FunctionalJavascriptTests/SortableTestTrait.php \Drupal\FunctionalJavascriptTests\SortableTestTrait::sortableAfter()
Simulates a drag moving an element after its sibling in the same container.
Parameters
string $item: The HTML selector for the element to be moved.
string $target: The HTML selector for the sibling element.
string $from: The HTML selector for the element container.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ SortableTestTrait.php, line 72
Class
- SortableTestTrait
- Provides functions for simulating sort changes.
Namespace
Drupal\FunctionalJavascriptTestsCode
protected function sortableAfter($item, $target, $from) {
$item = addslashes($item);
$target = addslashes($target);
$from = addslashes($from);
$script = <<<JS
(function (src, to) {
var sourceElement = document.querySelector(src);
var toElement = document.querySelector(to);
toElement.insertAdjacentElement('afterend', sourceElement);
})('{<span class="php-variable">$item</span>}', '{<span class="php-variable">$target</span>}')
JS;
$options = [
'script' => $script,
'args' => [],
];
$this
->getSession()
->getDriver()
->getWebDriverSession()
->execute($options);
$this
->sortableUpdate($item, $from);
}