summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <david@pybricks.com>2022-11-09 12:27:28 -0600
committerDamien George <damien@micropython.org>2022-11-11 13:21:28 +1100
commitea07ab04f80dbabd050aef972119e72c133aaa09 (patch)
tree4d92a97b87ff5719e8105a321004b02ca88467bf
parent0698dd72ea3b9d7897e63c6e219061bff8d162cf (diff)
webassembly/library: Make use of CustomEvent detail property.
This changes the CustomEvent for stdout to use the existing `detail` property of CustomEvent instead of adding a `data` property. Signed-off-by: David Lechner <david@pybricks.com>
-rw-r--r--ports/webassembly/README.md2
-rw-r--r--ports/webassembly/library.js3
2 files changed, 2 insertions, 3 deletions
diff --git a/ports/webassembly/README.md b/ports/webassembly/README.md
index 9ad04ccb9..89b8b1def 100644
--- a/ports/webassembly/README.md
+++ b/ports/webassembly/README.md
@@ -70,7 +70,7 @@ something to stdout. The following code demonstrates basic functionality:
<script>
document.addEventListener("micropython-print", function(e) {
let output = document.getElementById("micropython-stdout");
- output.innerText += e.data;
+ output.innerText += e.detail;
}, false);
var mp_js_startup = Module["onRuntimeInitialized"];
diff --git a/ports/webassembly/library.js b/ports/webassembly/library.js
index 6d9b07cff..fb31b0fe5 100644
--- a/ports/webassembly/library.js
+++ b/ports/webassembly/library.js
@@ -33,8 +33,7 @@ mergeInto(LibraryManager.library, {
process.stdout.write(b);
} else {
var c = String.fromCharCode(getValue(ptr + i, 'i8'));
- var printEvent = new CustomEvent('micropython-print');
- printEvent.data = c;
+ var printEvent = new CustomEvent('micropython-print', { detail: c });
document.dispatchEvent(printEvent);
}
}