New issue
Advanced search Search tips

Issue 758485 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug



Sign in to add a comment

Both Range.selectNode() and Range.selectNodeContents() copy node's content to clipboard

Reported by d...@moqups.com, Aug 24 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36

Steps to reproduce the problem:
1. In the first div, press Cmd + C / Ctrl + C to copy to the clipboard the Node, then paste it the textarea below
2. In the second div, press Cmd + C to copy to the clipboard, the Node's contents, then paste it in the textarea below

What is the expected behavior?
Not sure what the expected behavior is here, as I could not find the relevant spec that outlines it, but I would expect that selectNode and selectNodeContents would allow me to decide whether to include in the selection the Node's "outer html" vs. its "inner html". 

What went wrong?
Both methods result in the node's "inner html" to be copied to the Clipboard in Chrome (and Safari). 

Both methods result in the node's "outer html" to be copied to the Clipboard in Firefox.

Did this work before? N/A 

Does this work in other browsers? N/A

Chrome version: 60.0.3112.101  Channel: stable
OS Version: OS X 10.12.6
Flash Version: 

I'd appreciate it if you helped me understand if this is expected behavior, and which spec to look into (I'd like to file an issue with them, if necessary), because I think there needs to be a way to decide if I want to select the node's content vs. the entire node.
 
selectnode.html
1.5 KB View Download

Comment 1 by d...@moqups.com, Aug 24 2017

I've logged an issue here, as it seemed the most appropriate: https://github.com/w3c/editing/issues/168

Comment 2 by d...@moqups.com, Aug 24 2017

As a workaround we can manually set `e.clipboardData.setData()` for `text/plain` and `text/html`, in which case, will it be safe to just set their content to `node.textContent`, and `XMLSerializer.serializeToString(node)` or `Node.outerHMTL`, respectively, as their content, or is there additional sanitization in the process? If that's that's the case, can you kindly direct me to the source code for where this happens, to see if there's something we should do client-side as well?

Comment 3 by yosin@chromium.org, Aug 24 2017

Components: -Blink>Editing Blink>Editing>Selection
Status: WontFix (was: Unconfirmed)
Mark WontFix since this is work as expected.

On "copy", Blink put selected range into clipboard after visible canonicalization
of specified range.

In this case, visible canonicalization shrinks selected range to text and exclude
leading/trailing whitespaces of start/end tag, e.g.
 - ^<span>    foo   </span>| => <span>  ^foo|   </span>
 - <span>^    foo   |</span> => <span>  ^foo|   </span>

Note: WebKit also does visible canonicalization.







Comment 4 by d...@moqups.com, Aug 24 2017

Thanks for the clarification! It seems that at this moment we will need to do setData('text/html') to harmonize cross-browser behavior. 

Sign in to add a comment