2 ms·
Because once the declarative HTML has been transformed into DOM objects, they are not just dumb data but OO-style rich objects. They have identity and internal
by kccqzy 8y ago
Because once the declarative HTML has been transformed into DOM objects, they are not just dumb data but OO-style rich objects. They have identity and internal state, which may or may not be reflected by their markup (not even innerHTML or outerHTML). For example when you attach an event handler, that object gains this behavior. If perhaps that object has some other change, and a DOM-diff library stupidly deletes the original DOM and add a new one, that could be lost. The same for typed text in <input> fields.
Simply put, the OO nature of the DOM complicates things. If DOM were just a simple recursive tree data structure of which HTML is a serialization, there would be no such issues.