2 ms·
> Any collapsing, un collapsing, ignoring, and so an are handled by manipulating these nodes further. But this is the semantics of the HTML itself. Well the po
by lmm 2y ago
> Any collapsing, un collapsing, ignoring, and so an are handled by manipulating these nodes further. But this is the semantics of the HTML itself.
Well the post I replied to talked about the DOM, and as a description of the behaviour of the DOM I don't think your description is accurate - when you write
"<a href="ABC">foo </a> bar" you only end up with one space character contained in a DOM text node, not two.
- tsimionescu 2y agoYou 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.