diff --git a/core/modules/comment/comment-entity-form.es6.js b/core/modules/comment/comment-entity-form.es6.js index 00a3404ab3..bebda79017 100644 --- a/core/modules/comment/comment-entity-form.es6.js +++ b/core/modules/comment/comment-entity-form.es6.js @@ -3,7 +3,7 @@ * Attaches comment behaviors to the entity form. */ -(function ($, Drupal) { +(($, Drupal) => { /** * * @type {Drupal~behavior} @@ -11,7 +11,14 @@ Drupal.behaviors.commentFieldsetSummaries = { attach(context) { const $context = $(context); - $context.find('fieldset.comment-entity-settings-form').drupalSetSummary(context => Drupal.checkPlain($(context).find('.js-form-item-comment input:checked').next('label').text())); + $context.find('.js-comment-settings-form').drupalSetSummary((formElement) => { + const widgetSelector = $(formElement).data('comment-widget-selector'); + return $context + .find(`[data-drupal-selector="${widgetSelector}"]`) + .find('input:checked') + .next('label') + .text(); + }); }, }; -}(jQuery, Drupal)); +})(jQuery, Drupal); diff --git a/core/modules/comment/comment-entity-form.js b/core/modules/comment/comment-entity-form.js index f06b34b2e4..29ea5aebef 100644 --- a/core/modules/comment/comment-entity-form.js +++ b/core/modules/comment/comment-entity-form.js @@ -9,13 +9,9 @@ Drupal.behaviors.commentFieldsetSummaries = { attach: function attach(context) { var $context = $(context); - $context.find('.js-comment-settings-form').drupalSetSummary(function (context) { - var widgetSelector = $(context).data('comment-widget-selector'); - return $context - .find('[data-drupal-selector="' + widgetSelector + '"]') - .find('input:checked') - .next('label') - .text(); + $context.find('.js-comment-settings-form').drupalSetSummary(function (formElement) { + var widgetSelector = $(formElement).data('comment-widget-selector'); + return $context.find('[data-drupal-selector="' + widgetSelector + '"]').find('input:checked').next('label').text(); }); } }; diff --git a/core/modules/comment/tests/src/FunctionalJavascript/EntitySettingsFormTest.php b/core/modules/comment/tests/src/FunctionalJavascript/EntitySettingsFormTest.php index c91a789483..4994d2269c 100644 --- a/core/modules/comment/tests/src/FunctionalJavascript/EntitySettingsFormTest.php +++ b/core/modules/comment/tests/src/FunctionalJavascript/EntitySettingsFormTest.php @@ -11,57 +11,56 @@ * * @group comment */ -class EntitySettingsFormTest extends JavascriptTestBase -{ +class EntitySettingsFormTest extends JavascriptTestBase { - use CommentTestTrait; - use ContentTypeCreationTrait; + use CommentTestTrait; + use ContentTypeCreationTrait; - /** - * {@inheritdoc} - */ - public static $modules = ['comment', 'node']; + /** + * {@inheritdoc} + */ + public static $modules = ['comment', 'node']; - /** - * {@inheritdoc} - */ - protected function setUp() - { - parent::setUp(); - $this->createContentType(array('type' => 'article', 'name' => t('Article'))); - $this->addDefaultCommentField('node', 'article'); - } + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->createContentType([ + 'type' => 'article', + 'name' => 'Article', + ]); + $this->addDefaultCommentField('node', 'article'); + } - /** - * Tests if the vertical tab summary can be updated with JavaScript. - */ - public function testVerticalTabsSummary() - { + /** + * Tests if the vertical tab summary can be updated with JavaScript. + */ + public function testVerticalTabsSummary() { - $web_user = $this->drupalCreateUser([ - 'administer content types', - 'administer comments', - ]); - $this->drupalLogin($web_user); + $web_user = $this->drupalCreateUser([ + 'administer content types', + 'administer comments', + ]); + $this->drupalLogin($web_user); - $this->drupalGet('node/add/article'); - $this->assertSummary(t('Open')); - $this->click('[data-drupal-selector="edit-comment-0-status-1"]'); - $this->assertSummary(t('Closed')); - $this->click('[data-drupal-selector="edit-comment-0-status-2"]'); - $this->assertSummary(t('Open')); - } + $this->drupalGet('node/add/article'); + $this->assertSummary(t('Open')); + $this->click('[data-drupal-selector="edit-comment-0-status-1"]'); + $this->assertSummary(t('Closed')); + $this->click('[data-drupal-selector="edit-comment-0-status-2"]'); + $this->assertSummary(t('Open')); + } - /** - * Asserts that corresponding vertical tab has a correct summary. - * - * @param string $summary - * Summary value to check. - */ - protected function assertSummary($summary) - { - $condition = sprintf('jQuery(".is-selected .vertical-tabs__menu-item-summary").text() == "%s"', $summary); - $this->assertJsCondition($condition); - } + /** + * Asserts that corresponding vertical tab has a correct summary. + * + * @param string $summary + * Summary value to check. + */ + protected function assertSummary($summary) { + $condition = sprintf('jQuery(".is-selected .vertical-tabs__menu-item-summary").text() == "%s"', $summary); + $this->assertJsCondition($condition); + } }