Re: review of HTML5 differences from HTML4

I'm particularly bothered by the toString method of the selection object
returned by window.getSelection. Theoretically I think it should be the
equivalent of the plain-text copied to the clipboard by pressing Ctrl-C, but
strictly reading the spec it says that it is the concatenation of the ranges
of character data. So using the following sample code snippet:

<p>Paragraph 1</p><p>Paragraph 2</p>

If the resulting text is highlighted and copied, it will have a blank line
between "Paragraph 1" and "Paragraph 2", and Ctrl-C will copy the two
paragraphs formatted as expected with a blank line between them. However, if
the user agent is strictly adhering the spec,
window.getSelection().toString() will simply return "Paragraph 1Paragraph
2".

Is there some workaround to correctly determine what the selection is and
what will be copied to the clipboard on a Ctrl-C action?

Note: Opera adheres to the spec and toString returns "Paragraph 1Paragraph
2". In Firefox, you get the same thing that you would get by pressing
Ctrl-C: "Paragraph 1\n\nParagraph 2", which seems to be the more appropriate
action (though wrong, according to the spec).

Received on Saturday, 5 June 2010 20:06:11 UTC