问题
I'm working on an rich-text editor that will be using ContentEditable. It's imperative that a document that is loaded into the browser (from the web server) is not altered in any way by the conversion to DOM, and then back to HTML alone (assuming the user has not made any changes).
It's alright if the HTML document is modified the first time it's created and saved by a browser, but subsequently should not occur again, which simply requires that all browsers will produce the same DOM based on equivalent HTML, and the same HTML output based on equivalent DOMs. Is this something that I can rely upon?
回答1:
It's easy to demonstrate that the markup doesn't round-trip when the serialisation is performed with innerHTML or outerHTML.
Take markup that starts as <div id='mydiv'></div>
. In IE9 that becomes <div id="mydiv"></div>
. In IE8, it becomes <DIV id=mydiv></DIV>
来源:https://stackoverflow.com/questions/12331997/is-the-conversion-from-html-to-dom-and-back-to-html-standardized