diff --git a/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php index 659cb27..b62ba69 100644 --- a/core/lib/Drupal/Component/Utility/Html.php +++ b/core/lib/Drupal/Component/Utility/Html.php @@ -35,7 +35,7 @@ class Html { protected static $seenIds; /** - * Contains if the current request was sent via AJAX. + * Stores whether the current request was sent via AJAX. * * @var bool */ @@ -147,7 +147,7 @@ public static function getUniqueId($id) { return static::getId($id) . '--' . Crypt::randomBytesBase64(8); } - // seenIdsInit is only useful for tests anymore. + // seenIdsInit is now only useful during testing. if (!isset(static::$seenIdsInit)) { static::$seenIdsInit = array(); } diff --git a/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php index 83262f8..87f89d1 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AjaxSubscriber.php @@ -20,7 +20,7 @@ class AjaxSubscriber implements EventSubscriberInterface { /** - * Request parameter to indicate that a request is a drupal ajax request. + * Request parameter to indicate that a request is a Drupal Ajax request. */ const AJAX_REQUEST_PARAMETER = '_drupal_ajax'; diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 76ee918..39c7c37 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -377,7 +377,7 @@ Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format'; /** - * Request parameter to indicate that a request is a drupal ajax request. + * Request parameter to indicate that a request is a Drupal Ajax request. */ Drupal.ajax.AJAX_REQUEST_PARAMETER = '_drupal_ajax'; diff --git a/core/modules/file/src/Element/ManagedFile.php b/core/modules/file/src/Element/ManagedFile.php index 740791c..a6fe4f8 100644 --- a/core/modules/file/src/Element/ManagedFile.php +++ b/core/modules/file/src/Element/ManagedFile.php @@ -142,7 +142,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st $element['#files'] = !empty($fids) ? File::loadMultiple($fids) : FALSE; $element['#tree'] = TRUE; - // Generate a wrapper html ID. All we need is that its unique. + // Generate a unique wrapper HTML ID. $ajax_wrapper_id = Html::getUniqueId('ajax-wrapper'); $ajax_settings = [ @@ -260,7 +260,7 @@ public static function processManagedFile(&$element, FormStateInterface $form_st $element['upload']['#attached']['drupalSettings']['file']['elements']['#' . $element['#id']] = $extension_list; } - // Let #id point of the file element, so the field label's 'for' corresponds + // Let #id point to the file element, so the field label's 'for' corresponds // with it. $element['#id'] = &$element['upload']['#id']; diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index d6ac7bd..54dba00 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -822,12 +822,12 @@ protected function assertThemeOutput($callback, array $variables = array(), $exp } /** - * Asserts that a field exists in the current page with a given xpath result. + * Asserts that a field exists in the current page with a given Xpath result. * * @param \SimpleXmlElement[] $fields * Xml elements. * @param string $value - * Value of the field to assert. You may pass in NULL (default) to skip + * (optional) Value of the field to assert. You may pass in NULL (default) to skip * checking the actual value, while still checking that the field exists. * @param string $message * (optional) A message to display with the assertion. Do not translate diff --git a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php index 3026a17..b634354 100644 --- a/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php +++ b/core/tests/Drupal/Tests/Component/Utility/HtmlTest.php @@ -151,8 +151,9 @@ public function providerTestHtmlGetUniqueId() { public function testHtmlGetUniqueIdWithAjaxIds($expected, $source) { Html::setIsAjax(TRUE); $id = Html::getUniqueId($source); - $t = explode('--', $id); - $expected .= $t[1]; + + $random_suffix = substr($id, strlen($source) + 2); + $expected = $expected . $random_suffix; $this->assertSame($expected, $id); } @@ -165,6 +166,9 @@ public function testHtmlGetUniqueIdWithAjaxIds($expected, $source) { public function providerTestHtmlGetUniqueIdWithAjaxIds() { return array( array('test-unique-id1--', 'test-unique-id1'), + // Note, we truncate two hyphens at the end. + // @see \Drupal\Component\Utility\Html::getId() + array('test-unique-id1---', 'test-unique-id1--'), array('test-unique-id2--', 'test-unique-id2'), ); }