Skip to content

Commit 2b9ce0c

Browse files
committed
Suppress unnecessary clipboard errors
1 parent 52412f0 commit 2b9ce0c

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

squeak.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -896,18 +896,14 @@ function createSqueakDisplay(canvas, options) {
896896
// more copy/paste
897897
if (navigator.clipboard) {
898898
// new-style copy/paste (all modern browsers)
899-
display.readFromSystemClipboard = () => navigator.clipboard.readText()
899+
display.readFromSystemClipboard = () => display.handlingEvent &&
900+
navigator.clipboard.readText()
900901
.then(text => display.clipboardString = text)
901-
.catch(err => {
902-
if (!display.handlingEvent) console.warn("reading from clipboard outside event handler");
903-
console.error("readFromSystemClipboard" + err.message);
904-
});
905-
display.writeToSystemClipboard = () => navigator.clipboard.writeText(display.clipboardString)
902+
.catch(err => console.error("readFromSystemClipboard " + err.message));
903+
display.writeToSystemClipboard = () => display.handlingEvent &&
904+
navigator.clipboard.writeText(display.clipboardString)
906905
.then(() => display.clipboardStringChanged = false)
907-
.catch(err => {
908-
if (!display.handlingEvent) console.warn("writing to clipboard outside event handler");
909-
console.error("writeToSystemClipboard" + err.message);
910-
});
906+
.catch(err => console.error("writeToSystemClipboard " + err.message));
911907
} else {
912908
// old-style copy/paste
913909
document.oncopy = function(evt, key) {

vm.input.browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Object.extend(Squeak.Primitives.prototype,
4343
clipBoardPromise
4444
.then(() => this.vm.popNandPush(1, this.makeStString(this.display.clipboardString)))
4545
.catch(() => this.vm.popNandPush(1, this.vm.nilObj))
46-
.finally(() => unfreeze());
46+
.finally(unfreeze);
4747
} else {
4848
if (typeof(this.display.clipboardString) !== 'string') return false;
4949
this.vm.popNandPush(1, this.makeStString(this.display.clipboardString));

0 commit comments

Comments
 (0)