function EntityReferenceWidgetTest::sortableUpdate

Same name in other branches
  1. 9 core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest::sortableUpdate()
  2. 11.x core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EntityReferenceWidgetTest::sortableUpdate()

Overrides SortableTestTrait::sortableUpdate

File

core/modules/media_library/tests/src/FunctionalJavascript/EntityReferenceWidgetTest.php, line 582

Class

EntityReferenceWidgetTest
Tests the Media library entity reference widget.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function sortableUpdate($item, $from, $to = NULL) {
    // See core/modules/media_library/js/media_library.widget.js.
    $script = <<<JS
(function (\$) {
    var selection = document.querySelectorAll('.js-media-library-selection');
    selection.forEach(function (widget) {
        \$(widget).children().each(function (index, child) {
            \$(child).find('.js-media-library-item-weight').val(index);
        });
    });
})(jQuery)

JS;
    $this->getSession()
        ->executeScript($script);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.