[simulator/web] Use specialHTMLTargets to allow picking a canvas

This commit is contained in:
Romain Goyet
2021-02-23 21:03:18 -05:00
committed by Léa Saviot
parent 2703f9a506
commit 32d591317b

View File

@@ -18,4 +18,13 @@ Module["preRun"] = function () {
ENV[key] = Module['env'][key];
}
}
/* When figuring up in which DOM element to draw, SDL2/emscripten looks for
* an element with an id of "canvas". That's pretty annoying because it pretty
* much prevents us from running multiple instances of Epsilon in a single web
* page even if Epsilon is built using MODULARIZE=1.
* Enters specialHTMLTargets. This is a nifty hack that allows one to override
* DOM node lookups made by Emscripten! Using this feature, we can instruct
* emscripten to use a custom element when looking for "#canvas".
* See https://github.com/emscripten-core/emscripten/pull/10659 */
specialHTMLTargets["#canvas"] = Module.canvas;
}