RE: [whatwg] void elements vs. content model = "empty"

On Wed, 20 Jun 2007, Kristof Zelechovski wrote:
> Well, thanks for the explanation.  The explanation lacks one point 
> though: such content will simply get dropped by innerHTML.  I do not 
> have an opinion whether it is right or wrong, I just wanted to say it 
> explicitly because it sounds odd.

Yes, the HTML version of innerHTML has a number of limitations. This is 
discussed in the spec:

# If the element's contents are not conformant, it is possible that the 
# roundtripping through innerHTML will not work. For instance, if the 
# element is a textarea element to which a Comment node has been appended, 
# then assigning innerHTML to itself will result in the comment being 
# displayed in the text field. Similarly, if, as a result of DOM 
# manipulation, the element contains a comment that contains the literal 
# string "-->", then when the result of serialising the element is parsed, 
# the comment will be truncated at that point and the rest of the comment 
# will be interpreted as markup. Another example would be making a script 
# element contain a text node with the text string "</script>".

Actually I should update that to mention that it can happen with 
conformant content as well.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Tuesday, 19 June 2007 23:08:00 UTC