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>
This commit is contained in:
David Lechner 2022-11-09 12:27:28 -06:00 committed by Damien George
parent 0698dd72ea
commit ea07ab04f8
2 changed files with 2 additions and 3 deletions

View File

@ -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"];

View File

@ -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);
}
}