mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
copy/paste: Try to fix Casper flake and add comments.
I think this will fix a Casper flake where there was a race window with multiple temp DOM elements holding copied text. I also add a comment to the code I think causes this race for the tests.
This commit is contained in:
@@ -141,8 +141,23 @@ function copy_handler() {
|
||||
$('body').append(div);
|
||||
selection.selectAllChildren(div[0]);
|
||||
|
||||
// After the copy has happened, delete the div and
|
||||
// change the selection back to the original selection
|
||||
/*
|
||||
The techniques we use in this code date back to
|
||||
2013 and may be obsolete today (and may not have
|
||||
been even the best workaround back then).
|
||||
|
||||
https://github.com/zulip/zulip/commit/fc0b7c00f16316a554349f0ad58c6517ebdd7ac4
|
||||
|
||||
The idea is that we build a temp div, return from
|
||||
this function, let jQuery process the selection,
|
||||
then restore the selection on a zero-second timer
|
||||
back to the original selection.
|
||||
|
||||
Do not be afraid to change this code if you understand
|
||||
how modern browsers deal with copy/paste. Just test
|
||||
your changes carefully.
|
||||
*/
|
||||
|
||||
window.setTimeout(function () {
|
||||
selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
|
||||
Reference in New Issue
Block a user