Is the conversion from HTML to DOM and back to HTML standardized?

一个人想着一个人 提交于 2019-12-25 05:23:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!