Skip to content

Commit 1b7a86c

Browse files
committed
Generalized constructor
1 parent 7eeea1a commit 1b7a86c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

AngleSharp.Scripting.JavaScript/DomFunctionInstance.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
sealed class DomFunctionInstance : FunctionInstance
1010
{
1111
readonly MethodInfo _method;
12-
readonly DomNodeInstance _host;
12+
readonly EngineInstance _engine;
1313

14-
public DomFunctionInstance(DomNodeInstance host, MethodInfo method)
15-
: base(host.Engine, method.GetParameterNames(), null, false)
14+
public DomFunctionInstance(EngineInstance engine, MethodInfo method)
15+
: base(engine.Jint, method.GetParameterNames(), null, false)
1616
{
17-
_host = host;
17+
_engine = engine;
1818
_method = method;
1919

2020
FastAddProperty("toString", new ClrFunctionInstance(Engine, ToString), true, false, true);
@@ -30,9 +30,8 @@ public override JsValue Call(JsValue thisObject, JsValue[] arguments)
3030
{
3131
try
3232
{
33-
var engine = _host.Context;
34-
var parameters = engine.BuildArgs(_method, arguments);
35-
return _method.Invoke(node.Value, parameters).ToJsValue(engine);
33+
var parameters = _engine.BuildArgs(_method, arguments);
34+
return _method.Invoke(node.Value, parameters).ToJsValue(_engine);
3635
}
3736
catch
3837
{

0 commit comments

Comments
 (0)