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:
parent
0698dd72ea
commit
ea07ab04f8
@ -70,7 +70,7 @@ something to stdout. The following code demonstrates basic functionality:
|
|||||||
<script>
|
<script>
|
||||||
document.addEventListener("micropython-print", function(e) {
|
document.addEventListener("micropython-print", function(e) {
|
||||||
let output = document.getElementById("micropython-stdout");
|
let output = document.getElementById("micropython-stdout");
|
||||||
output.innerText += e.data;
|
output.innerText += e.detail;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
var mp_js_startup = Module["onRuntimeInitialized"];
|
var mp_js_startup = Module["onRuntimeInitialized"];
|
||||||
|
@ -33,8 +33,7 @@ mergeInto(LibraryManager.library, {
|
|||||||
process.stdout.write(b);
|
process.stdout.write(b);
|
||||||
} else {
|
} else {
|
||||||
var c = String.fromCharCode(getValue(ptr + i, 'i8'));
|
var c = String.fromCharCode(getValue(ptr + i, 'i8'));
|
||||||
var printEvent = new CustomEvent('micropython-print');
|
var printEvent = new CustomEvent('micropython-print', { detail: c });
|
||||||
printEvent.data = c;
|
|
||||||
document.dispatchEvent(printEvent);
|
document.dispatchEvent(printEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user