3 ms·
document.write called on a loaded document? Reopen it and clear its contents. Yes because that makes sense and I wouldn’t want that to be an error state. Oh Jav
by leetrout 7y ago
document.write called on a loaded document? Reopen it and clear its contents. Yes because that makes sense and I wouldn’t want that to be an error state. Oh JavaScript.
(But also, just don’t use document.write)
- shawnz 7y agoWhat if you actually wanted to replace the entire document contents with a new document? Why should that be an error? The fact that the meaning of the API is commonly misunderstood is not (necessarily) a fault of the API
- leetrout 7y agoSure, something like a .clear or similar but the default behavior of clearing a loaded document by calling open on it is strange compared to what you would expect to happen with “normal” files/streams. Edit to add: I think calling write on a loaded document should have been an exceptional case and you should have had to explicitly call something to unload, replace or clear it.