From c24f5585b29a52c32315dbed49aa66c7fe94caa0 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Jun 2020 16:42:38 +0200 Subject: [PATCH] LibWeb: Let HTMLScriptElement call Document::run_javascript() The fewer places we invoke the JS parser the better. Unless we have some specific reason to parse manually, we can just call Document. --- Libraries/LibWeb/DOM/Document.cpp | 2 -- Libraries/LibWeb/DOM/HTMLScriptElement.cpp | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Libraries/LibWeb/DOM/Document.cpp b/Libraries/LibWeb/DOM/Document.cpp index cacd240404..9bd60d24d3 100644 --- a/Libraries/LibWeb/DOM/Document.cpp +++ b/Libraries/LibWeb/DOM/Document.cpp @@ -412,8 +412,6 @@ JS::Value Document::run_javascript(const StringView& source) parser.print_errors(); return JS::js_undefined(); } - dbg() << "Document::run_javascript('" << source << "') will run:"; - program->dump(0); return document().interpreter().run(document().interpreter().global_object(), *program); } diff --git a/Libraries/LibWeb/DOM/HTMLScriptElement.cpp b/Libraries/LibWeb/DOM/HTMLScriptElement.cpp index e7552211b3..481a65cd81 100644 --- a/Libraries/LibWeb/DOM/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/DOM/HTMLScriptElement.cpp @@ -55,13 +55,7 @@ void HTMLScriptElement::set_non_blocking(Badge, bool non_blo void HTMLScriptElement::execute_script() { - auto parser = JS::Parser(JS::Lexer(m_script_source)); - auto program = parser.parse_program(); - if (parser.has_errors()) { - parser.print_errors(); - return; - } - document().interpreter().run(document().interpreter().global_object(), *program); + document().run_javascript(m_script_source); } void HTMLScriptElement::prepare_script(Badge)