mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 22:45:06 +00:00
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.
This commit is contained in:
parent
3a5af6ef61
commit
c24f5585b2
2 changed files with 1 additions and 9 deletions
|
@ -412,8 +412,6 @@ JS::Value Document::run_javascript(const StringView& source)
|
||||||
parser.print_errors();
|
parser.print_errors();
|
||||||
return JS::js_undefined();
|
return JS::js_undefined();
|
||||||
}
|
}
|
||||||
dbg() << "Document::run_javascript('" << source << "') will run:";
|
|
||||||
program->dump(0);
|
|
||||||
return document().interpreter().run(document().interpreter().global_object(), *program);
|
return document().interpreter().run(document().interpreter().global_object(), *program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,13 +55,7 @@ void HTMLScriptElement::set_non_blocking(Badge<HTMLDocumentParser>, bool non_blo
|
||||||
|
|
||||||
void HTMLScriptElement::execute_script()
|
void HTMLScriptElement::execute_script()
|
||||||
{
|
{
|
||||||
auto parser = JS::Parser(JS::Lexer(m_script_source));
|
document().run_javascript(m_script_source);
|
||||||
auto program = parser.parse_program();
|
|
||||||
if (parser.has_errors()) {
|
|
||||||
parser.print_errors();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
document().interpreter().run(document().interpreter().global_object(), *program);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLScriptElement::prepare_script(Badge<HTMLDocumentParser>)
|
void HTMLScriptElement::prepare_script(Badge<HTMLDocumentParser>)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue