From 9c2701439a626ce755b0da95d508bac910c62851 Mon Sep 17 00:00:00 2001 From: Adel Khamatov Date: Tue, 24 Dec 2024 09:20:57 +0200 Subject: [PATCH] Core: renderer, `removeAttr` remove an attribute from a set of elements (T1261932) (#28595) --- .../js/__internal/core/m_renderer_base.ts | 5 ++++- .../tests/DevExpress.core/renderer.tests.js | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/devextreme/js/__internal/core/m_renderer_base.ts b/packages/devextreme/js/__internal/core/m_renderer_base.ts index 490430412077..4dfcf7b785b6 100644 --- a/packages/devextreme/js/__internal/core/m_renderer_base.ts +++ b/packages/devextreme/js/__internal/core/m_renderer_base.ts @@ -115,7 +115,10 @@ initRender.prototype.attr = function (attrName, value) { }; initRender.prototype.removeAttr = function (attrName) { - this[0] && domAdapter.removeAttribute(this[0], attrName); + this.each(function (_, element) { + domAdapter.removeAttribute(element, attrName); + }); + return this; }; diff --git a/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js b/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js index c5c40b1ceabd..f5e6f90bb34c 100644 --- a/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.core/renderer.tests.js @@ -372,6 +372,21 @@ QUnit.test('Add/remove atribute', function(assert) { assert.equal(!!$element.get(0).getAttribute('readonly'), true, 'element readOnly attribute'); $element.attr('readonly', false); assert.equal($element.get(0).getAttribute('readonly'), undefined, 'element readOnly attribute'); +}); + +QUnit.test('Remove an attribute from the whole set of elements (T1261932)', function(assert) { + const fixture = document.getElementById('qunit-fixture'); + + const $wrapper = renderer('
').html('
1
2
'); + const $allInnerElements = $wrapper.find('div'); + + fixture.appendChild($allInnerElements.get(0)); + + $allInnerElements.removeAttr('readonly'); + + $allInnerElements.each(function(_, element) { + assert.equal(element.getAttribute('readonly'), undefined, 'element readOnly attribute'); + }); });