From 6aa2e3ff7e7a14e4aca11460cf0db77b5e40d77a Mon Sep 17 00:00:00 2001 From: Matthew Andres Moreno Date: Thu, 18 Apr 2024 15:24:35 -0400 Subject: [PATCH] Work around bug involving fonts/DOM injection Adding font before parent container has been added to DOM crashes on pageload. Error message is TextArea.js:6 Uncaught TypeError: ea[v[((v[(a >> 2)] + 68) >> 2)]] is not a function at Ml (TextArea.js:6:1555) at Array.Sr (TextArea.js:6:9333) at qi (TextArea.js:5:252871) at Rp (TextArea.js:5:91855) at Module._main (TextArea.js:15:78841) at callMain (TextArea.js:15:81058) at doRun (TextArea.js:15:81455) at run (TextArea.js:15:81627) at runCaller (TextArea.js:15:80913) at removeRunDependency (TextArea.js:15:4729) Ml @ TextArea.js:6 Sr @ TextArea.js:6 qi @ TextArea.js:5 Rp @ TextArea.js:5 Module._main @ TextArea.js:15 callMain @ TextArea.js:15 doRun @ TextArea.js:15 run @ TextArea.js:15 runCaller @ TextArea.js:15 removeRunDependency @ TextArea.js:15 applyMemoryInitializer @ TextArea.js:15 xhr.onload @ TextArea.js:1 load (async) readAsync @ TextArea.js:1 doBrowserLoad @ TextArea.js:15 runMemoryInitializer @ TextArea.js:15 receiveInstance @ TextArea.js:15 receiveInstantiationResult @ TextArea.js:15 Promise.then (async) instantiateArrayBuffer @ TextArea.js:15 instantiateAsync @ TextArea.js:15 createWasm @ TextArea.js:15 (anonymous) @ TextArea.js:15 --- examples/web/TextArea.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/web/TextArea.cpp b/examples/web/TextArea.cpp index 4855d6ae84..d1fadadd57 100644 --- a/examples/web/TextArea.cpp +++ b/examples/web/TextArea.cpp @@ -23,11 +23,6 @@ int main() { doc << "

Testing!

"; - out1_font.SetColor("green"); - out2_font.SetColor("blue"); - text_reflect << out1_font; - text_reflect2 << out2_font; - text_area.SetCallback([](const std::string & in){ text_area.SetText("Changed!"); }); @@ -46,4 +41,10 @@ int main() }, "Update" ) << "
" << text_reflect << "

" << text_reflect2; + + out1_font.SetColor("green"); + out2_font.SetColor("blue"); + text_reflect << out1_font; + text_reflect2 << out2_font; + }