A user-select: none span at the end of a paragraph hides the EOL from the clipboard
Categories
(Core :: DOM: Copy & Paste and Drag & Drop, defect)
Tracking
()
People
(Reporter: mt, Unassigned)
References
Details
If I construct HTML as follows
<style>.u { user-select: none; }</style>
<p>One<span class="u">.</span></p>
<p>Two<span class="u">.</span></p>
<p>Three<span class="u">.</span></p>
Copying the content of this HTML omits the periods, but it also omits any end-of-line characters that might be expected. Selecting the entire document above, copying, then pasting into a text editor produces the string "OneTwoThree" when copied from Firefox. In Edge, it produces "One\r\n\r\nTwo\r\n\r\nThree", which is closer to what you might expect.
Background: IETF documents include a pilcrow at the end of each paragraph. This exists to provide a link to that paragraph, but these are styled user-select: none so that copy and paste does not pick them up as noise. Usually, this bug is easy to work around, but I recently had cause to dump a longer document using copy-paste, which hit this bug.
Bonus bug:
The following is quite surprising.
<p>One<span class="u">.</span><br/>Two</p>
Rather than copy a single end-of-line in this case, Firefox includes three.
Updated•2 years ago
|
This will be fixed by the fix of bug 1998858.
Currently, Gecko starts new range at next leaf after a non-selectable node. Therefore, in the case, the start boundary of the following paragraph is not contained in the range. However, bug 1998858 will make Gecko stop excluding non-selectable nodes from the user selected range. Therefore, the start boundary of the paragraph will be selected and serialized when copied into the clipboard.
Description
•