diff --git a/src/client/utils/html.js b/src/client/utils/html.js index 18d2ad8d4..b61e365eb 100644 --- a/src/client/utils/html.js +++ b/src/client/utils/html.js @@ -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); diff --git a/test/client/fixtures/sandbox/code-instrumentation/getters-test.js b/test/client/fixtures/sandbox/code-instrumentation/getters-test.js index c3b268c74..fe005d71e 100644 --- a/test/client/fixtures/sandbox/code-instrumentation/getters-test.js +++ b/test/client/fixtures/sandbox/code-instrumentation/getters-test.js @@ -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 = ''; + var div = document.createElement('div'); + + setProperty(div, 'innerHTML', htmlText); + + var a = div.firstChild; + + strictEqual(a.outerHTML, processHtml(htmlText)); + strictEqual(getProperty(a, 'outerHTML'), htmlText); +});