Skip to content

Instantly share code, notes, and snippets.

@Boldewyn
Last active January 1, 2016 11:29
Show Gist options
  • Save Boldewyn/8138833 to your computer and use it in GitHub Desktop.
Save Boldewyn/8138833 to your computer and use it in GitHub Desktop.
ZeroClipboard: Minimal testcase for mal-functioning copying

The set-up: place both files in a directory, add ZeroClipboard 1.2.3 and Require.JS so that they're found.

Open testcase.html and watch console output: Sometimes the text is copied, sometimes not:

22:16:08.959 "Copied text to clipboard: " testcase.js:5
22:16:10.141 "Copied text to clipboard: a" testcase.js:5
22:16:11.544 "Copied text to clipboard: a" testcase.js:5
22:16:12.057 "Copied text to clipboard: " testcase.js:5
22:16:12.816 "Copied text to clipboard: a" testcase.js:5

Full issue report is here: zeroclipboard/zeroclipboard#298

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<button data-clipboard-text="a" id="test" type="button">copy to clipboard</button>
<script src="components/requirejs/require.js"></script>
<script>
require.config({
"baseUrl": ".",
"urlArgs": "bust=" + (new Date()).getTime(),
"paths": {
"zeroclipboard": "components/zeroclipboard/ZeroClipboard"
}
});
require(['testcase']);
</script>
</body>
</html>
require(['zeroclipboard'], function(ZeroClipboard) {
var clip = new ZeroClipboard(document.getElementById("test"));
clip.on( 'complete', function ( client, args ) {
console.log("Copied text to clipboard: " + args.text );
} );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment