[Webkit-unassigned] [Bug 177715] clipboardData.setData() fails on iOS with certain kind of selections.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sat Sep 30 23:35:27 PDT 2017
https://bugs.webkit.org/show_bug.cgi?id=177715
--- Comment #1 from Wenson Hsieh <wenson_hsieh at apple.com> ---
(In reply to Lucas Garron from comment #0)
> As documented in https://bugs.webkit.org/show_bug.cgi?id=156529 , Safari
> doesn't allow document.execCommand("copy") when there is no selection.
> It is possible work around this but by creating a temporary selection:
> https://bugs.webkit.org/show_bug.cgi?id=156529#c4
>
> However, this workaround is broken on iOS. After the temporary selection is
> selected, document.queryCommandEnabled("copy") returns true and a function
> registered using document.addEventListener("copy", ...) fires. *However*,
> `event.clipboardData.setData()` has no effect.
>
> Consider the following sample:
>
> <script>
> document.addEventListener("copy", function(e) {
> e.clipboardData.setData("text/plain", "This is plain text.");
> console.log(e.clipboardData.getData("text/plain"));
> e.preventDefault();
> });
>
> function copy() {
> var sel = document.getSelection();
> var range = document.createRange();
> range.selectNodeContents(document.body);
> sel.removeAllRanges();
> sel.addRange(range);
> document.execCommand("copy");
> window.getSelection().removeAllRanges();
> }
> </script>
> <button onclick='copy()'>Copy text (plain)</button>
>
> The `console.log(...)` line prints "This is plain text." on desktop Safari,
> but a blank string on iOS.
> Consequently, the clipboard is emptied (even if it contained something
> before).
This is working for me using ToT WebKit, on iOS 11.
I'm pretty sure Ryosuke and I fixed this with recent work around enhanced pasteboard/DataTransfer support in WebKit.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20171001/7fd187c4/attachment.html>
More information about the webkit-unassigned
mailing list