Skip to content

Commit

Permalink
Core: renderer, removeAttr remove an attribute from a set of elemen…
Browse files Browse the repository at this point in the history
…ts (T1261932) (#28595)
  • Loading branch information
chaosmirage authored Dec 24, 2024
1 parent eab637b commit 9c27014
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/devextreme/js/__internal/core/m_renderer_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div>').html('<div readonly="true">1</div><div readonly="true">2</div>');

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');
});
});

0 comments on commit 9c27014

Please sign in to comment.