lgarron/clipboard-polyfill

Edge <17 doesn't write out proper CF_HTML

zbjornson opened this issue · 3 comments

FYI on a compatibility issue... Calling clipboardData.setData("text/html", data) writes the data argument verbatim in Edge 16.16299 and earlier. That means your "DOM node" test results in the clipboard containing this (according to a low-level clipboard inspector):

<span xmlns="http://www.w3.org/1999/xhtml" id="markup-dom-copy-source" style="font-family: Helvetica;"><i><span style="font-size: 150%">T</span>his</i> <span style="background: orange; padding: 0px 2px">will be</span> <b>copied</b>.</span>

which isn't valid CF_HTML.

Chrome does it correctly:

Version:0.9
StartHTML:0000000105
EndHTML:0000000416
StartFragment:0000000141
EndFragment:0000000380
<html>
<body>
<!--StartFragment--><span xmlns="http://www.w3.org/1999/xhtml" id="markup-dom-copy-source" style="font-family: Helvetica;"><i><span style="font-size: 150%">T</span>his</i> <span style="background: orange; padding: 0px 2px">will be</span> <b>copied</b>.</span><!--EndFragment-->
</body>
</html>

as does FF:

Version:0.9
StartHTML:00000097
EndHTML:00000406
StartFragment:00000131
EndFragment:00000370
<html><body>
<!--StartFragment--><span xmlns="http://www.w3.org/1999/xhtml" id="markup-dom-copy-source" style="font-family: Helvetica;"><i><span style="font-size: 150%">T</span>his</i> <span style="background: orange; padding: 0px 2px">will be</span> <b>copied</b>.</span><!--EndFragment-->
</body>
</html>

FWIW, I think these are the relevant bits of FF's and Chrome's source that writes the CF_HTML format: https://dxr.mozilla.org/mozilla-central/source/widget/windows/nsDataObj.cpp#1927, https://cs.chromium.org/chromium/src/ui/base/clipboard/clipboard_util_win.cc?q=StartFragment&sq=package:chromium&dr=C&l=380.

It looks like this will be fixed in Edge 17, https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/14372529/, so maybe a wontfix here.

(Cool library btw!)

Thanks! I should add that to the caveats and the experiment table.

This seems to specific only to Windows; is that correct?
What's a good way for me to inspect the full clipboard contents on Windows to check something like this (e.g. what's your low-level clipboard inspector)?

Yep, specific to Windows.

I use http://www.peterbuettner.de/develop/tools/clipview/ to inspect the clipboard.

Actually, let's reopen this. Since it is a goal of this library to provide as much compatibility as is possible to polyfill, we may want to write CF_HTML manually for Edge UAs less than 17. I probably won't do it myself, but I'm happy to accept a PR for it.