W3C home > Mailing lists > Public > public-html-comments@w3.org > June 2010

Re: review of HTML5 differences from HTML4

From: Steve <afro.guy@gmail.com>
Date: Fri, 4 Jun 2010 15:56:16 -0500
Message-ID: <AANLkTimvyUdbyfj0yk130MmZoQmVDPuG1NAWqRPE9qfR@mail.gmail.com>
To: public-html-comments@w3.org
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 1 June 2011 00:14:02 GMT