named-slots icon indicating copy to clipboard operation
named-slots copied to clipboard

Attribute value should be re-encoded in outerHTML

Open treshugart opened this issue 8 years ago • 0 comments

Browsers seem to consistently report outerHTML / innerHTML between vendors but have odd behaviour when inspecting the values. For example:

const div = document.createElement('div');
div.innerHTML = '<div test="&quot;test1 &amp; test2&quot;">&quot;test1 &amp; test2&quot;</div>';
console.log(div.outerHTML);
console.log(div.innerHTML);
console.log(div.getAttribute('test');
console.log(div.firstChild.outerHTML);
console.log(div.firstChild.innerHTML);
console.log(div.firstChild.getAttribute('test');

To be consistent with their inconsistencies, we need to make outerHTML encode the values that it uses to serialise the attributes using node.value.

treshugart avatar Nov 14 '16 01:11 treshugart