2 ms·
> textContent seem to strip tags out of your string, so it's not really strict. Your mental model is a little off here. The character data returned will be com
by lucideer 4y ago
> textContent seem to strip tags out of your string, so it's not really strict.
Your mental model is a little off here. The character data returned will be coming from an internal representation of a node hierarchy - there are no tags, just a collection of nodes. The text data will be assembled from all text nodes in that collection and concatenated. Nothing is being stripped.
I'd guess the difference in original pre-spec features was innerText taking an internal representation that had been pre-processed for rendering before being stored in memory.
> innerText strictly preserves the HTML semantics of your string, textContent doesn't preserve anything.
It's the opposite. textContent preserves the semantics of your string in HTML source. innerText returns an intermediate representation of how you would expect your string to be handled by the rendering pipeline.
> Back then when those things were new, there was absolutely no way to store a string in an element and get it back later. Neither of those do this.
Not sure what you mean by this?