Closed 1RandomDev closed 1 year ago
+1
I am afraid I cannot see this behavior in chrome. my test code is like this
const div = document.createElement('div');
div.innerHTML = 'Hello, <br>World!';
console.log(div.innerText);
I add a new branch for this issue, but I don't think we should merge this, because chrome does the same.
I am afraid I cannot see this behavior in chrome. my test code is like this
const div = document.createElement('div'); div.innerHTML = 'Hello, <br>World!'; console.log(div.innerText);
Appears that it only works if the element is added to the DOM. Like this it's working fine.
const div = document.createElement('div');
document.body.appendChild(div);
div.innerHTML = 'Hello, <br>World!';
console.log(div.innerText);
Merged.
And thank you for feeding back.
When using the
innerText
function on elements that contain line breaks (<br>
) they get ignored in the output. A regular browser will convert them to \n characters. For exmpleHello<br>World
will result inHelloWorld
, but expected isHello\nWorld
.