Skip to content

Commit

Permalink
fix `Hammerhead overrides some attributes, that are used in non-stand…
Browse files Browse the repository at this point in the history
…ard way, with "null"` (close DevExpress#2347) (DevExpress#1583)
  • Loading branch information
intermike authored and AndreyBelym committed Feb 28, 2019
1 parent 587853b commit 137c102
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/client/utils/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function cleanUpHtml (html) {

find(container, STORED_ATTRS_SELECTOR, el => {
for (const { attr, storedAttr } of ATTRS_DATA_FOR_CLEANING) {
if (el.hasAttribute(attr))
if (el.hasAttribute(attr) && el.hasAttribute(storedAttr))
nativeMethods.setAttribute.call(el, attr, nativeMethods.getAttribute.call(el, storedAttr));
else if (attr === 'autocomplete')
nativeMethods.removeAttribute.call(el, attr);
Expand Down
12 changes: 12 additions & 0 deletions test/client/fixtures/sandbox/code-instrumentation/getters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,15 @@ test('getProperty function should not throw an error for document.all property (
ok(false);
}
});

test('leaving attributes, that are used in non-standard way, as they are (GH-2347)', function () {
var htmlText = '<input action="#test-me-out">';
var div = document.createElement('div');

setProperty(div, 'innerHTML', htmlText);

var a = div.firstChild;

strictEqual(a.outerHTML, processHtml(htmlText));
strictEqual(getProperty(a, 'outerHTML'), htmlText);
});

0 comments on commit 137c102

Please sign in to comment.