3 ms·
You can try it out and see that I'm right. I created a page like this: <div><a href="#">foo </a> bar</div> <script> divElement = document.getElements
by tsimionescu 2y ago
You can try it out and see that I'm right.
I created a page like this:
<div><a href="#">foo </a> bar</div>
<script>
divElement = document.getElementsByTagName("div")[0]
console.log('"' + divElement.childNodes[0].firstChild.data + '"')
console.log('"' + divElement.childNodes[1].data + '"')
</script>
And you'll see in the console:
"foo "
" bar"
So yes, the DOM itself contains what I and the poster before mentioned. It's the presentation layer that decides how to do space collapse.
As a bonus, you can also see that the DOM of the page has four children of `body`: `<div>`, then a text node with the content "\n\n", `<script>`, and another text node containing "\n".
Tested all this with a simple HTML I saved on disk and opened in Firefox.