diff -u b/core/lib/Drupal/Component/Utility/Html.php b/core/lib/Drupal/Component/Utility/Html.php
--- b/core/lib/Drupal/Component/Utility/Html.php
+++ b/core/lib/Drupal/Component/Utility/Html.php
@@ -102,16 +102,6 @@
}
/**
- * Sets the AJAX HTML IDs.
- *
- * @param string $ajax_html_ids
- * The AJAX HTML IDs, probably coming from the current request.
- */
- public static function setAjaxHtmlIds($ajax_html_ids = '') {
- static::$ajaxHTMLIDs = $ajax_html_ids;
- }
-
- /**
* Prepares a string for use as a valid HTML ID and guarantees uniqueness.
*
* This function ensures that each passed HTML ID value only exists once on
@@ -149,7 +139,7 @@
}
$id .= '-' . $request_nonce;
- return $id;
+ return Html::getId($id);
}
/**
@@ -183,13 +173,6 @@
}
/**
- * Resets the list of seen IDs.
- */
- public static function resetSeenIds() {
- static::$seenIds = NULL;
- }
-
- /**
* Normalizes an HTML snippet.
*
* This function is essentially \DOMDocument::normalizeDocument(), but
diff -u b/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php
--- b/core/modules/views_ui/src/ViewUI.php
+++ b/core/modules/views_ui/src/ViewUI.php
@@ -423,10 +423,6 @@
* rather than closing the ajax popup.
*/
public function addFormToStack($key, $display_id, $type, $id = NULL, $top = FALSE, $rebuild_keys = FALSE) {
- // Reset the cache of IDs. Drupal rather aggressively prevents ID
- // duplication but this causes it to remember IDs that are no longer even
- // being used.
- Html::resetSeenIds();
if (empty($this->stack)) {
$this->stack = array();
only in patch2:
unchanged:
--- a/core/lib/Drupal/Core/Form/FormBuilder.php
+++ b/core/lib/Drupal/Core/Form/FormBuilder.php
@@ -468,16 +468,6 @@ public function processForm($form_id, &$form, FormStateInterface &$form_state) {
}
$this->formValidator->validateForm($form_id, $form, $form_state);
- // drupal_html_id() maintains a cache of element IDs it has seen, so it
- // can prevent duplicates. We want to be sure we reset that cache when a
- // form is processed, so scenarios that result in the form being built
- // behind the scenes and again for the browser don't increment all the
- // element IDs needlessly.
- if (!FormState::hasAnyErrors()) {
- // In case of errors, do not break HTML IDs of other forms.
- Html::resetSeenIds();
- }
-
if (!$form_state->isRebuilding() && !FormState::hasAnyErrors()) {
if ($submit_response = $this->formSubmitter->doSubmitForm($form, $form_state)) {
return $submit_response;
only in patch2:
unchanged:
--- a/core/modules/block/src/Tests/BlockViewBuilderTest.php
+++ b/core/modules/block/src/Tests/BlockViewBuilderTest.php
@@ -92,9 +92,6 @@ public function testBasicRendering() {
$expected_output = implode("\n", $expected);
$this->assertEqual(drupal_render($output), $expected_output);
- // Reset the HTML IDs so that the next render is not affected.
- Html::resetSeenIds();
-
// Test the rendering of a block with a given title.
$entity = $this->controller->create(array(
'id' => 'test_block2',
only in patch2:
unchanged:
--- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
+++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
@@ -90,11 +90,6 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) {
\Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');
\Drupal::moduleHandler()->loadInclude('views', 'inc', 'includes/ajax');
- // Reset the cache of IDs. Drupal rather aggressively prevents ID
- // duplication but this causes it to remember IDs that are no longer even
- // being used.
- Html::resetSeenIds();
-
// check to see if this is the top form of the stack. If it is, pop
// it off; if it isn't, the user clicked somewhere else and the stack is
// now irrelevant.
only in patch2:
unchanged:
--- a/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
+++ b/core/tests/Drupal/Tests/Core/Form/FormTestBase.php
@@ -167,13 +167,6 @@ protected function setUp() {
}
/**
- * {@inheritdoc}
- */
- protected function tearDown() {
- Html::resetSeenIds();
- }
-
- /**
* Provides a mocked form object.
*
* @param string $form_id
only in patch2:
unchanged:
--- a/core/tests/Drupal/Tests/Core/Utility/HtmlTest.php
+++ b/core/tests/Drupal/Tests/Core/Utility/HtmlTest.php
@@ -100,17 +100,11 @@ public function testHtmlClass() {
* The expected result.
* @param string $source
* The string being transformed to an ID.
- * @param bool $reset
- * (optional) If TRUE, reset the list of seen IDs. Defaults to FALSE.
- *
* @dataProvider providerTestHtmlGetUniqueId
*
* @covers ::getUniqueId
*/
- public function testHtmlGetUniqueId($expected, $source, $reset = FALSE) {
- if ($reset) {
- Html::resetSeenIds();
- }
+ public function testHtmlGetUniqueId($expected, $source) {
$this->assertSame($expected, Html::getUniqueId($source));
}
@@ -143,18 +137,12 @@ public function providerTestHtmlGetUniqueId() {
* The expected result.
* @param string $source
* The string being transformed to an ID.
- * @param bool $reset
- * (optional) If TRUE, reset the list of seen IDs. Defaults to FALSE.
*
* @dataProvider providerTestHtmlGetUniqueIdWithAjaxIds
*
* @covers ::getUniqueId
*/
- public function testHtmlGetUniqueIdWithAjaxIds($expected, $source, $reset = FALSE) {
- if ($reset) {
- Html::resetSeenIds();
- }
- Html::setAjaxHtmlIds('test-unique-id1 test-unique-id2--3');
+ public function testHtmlGetUniqueIdWithAjaxIds($expected, $source) {
$this->assertSame($expected, Html::getUniqueId($source));
}