From 4aa81ef023fffd6fb2b5106d26cd32365cc4697d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Wed, 8 Jun 2022 16:23:20 +0300 Subject: [PATCH] Fix tests --- NiL.JS/Core/Interop/DictionaryWrapper.cs | 6 ++++++ NiL.JS/Extensions/JSValueExtensions.cs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/NiL.JS/Core/Interop/DictionaryWrapper.cs b/NiL.JS/Core/Interop/DictionaryWrapper.cs index a59db945c..747825acd 100644 --- a/NiL.JS/Core/Interop/DictionaryWrapper.cs +++ b/NiL.JS/Core/Interop/DictionaryWrapper.cs @@ -4,6 +4,12 @@ namespace NiL.JS.Core.Interop { + public static class DictionaryWrapper + { + public static DictionaryWrapper Of(IDictionary dictionary) + => new DictionaryWrapper(dictionary); + } + public sealed class DictionaryWrapper : JSObject { private readonly IDictionary _target; diff --git a/NiL.JS/Extensions/JSValueExtensions.cs b/NiL.JS/Extensions/JSValueExtensions.cs index d4b7f5778..8eddb08c7 100644 --- a/NiL.JS/Extensions/JSValueExtensions.cs +++ b/NiL.JS/Extensions/JSValueExtensions.cs @@ -176,8 +176,8 @@ public static T GetDefinedOr(this JSValue self, T defaultValue) if (self.Value is Function && typeof(Delegate).IsAssignableFrom(typeof(T))) return ((Function)self.Value).MakeDelegate(); - if (typeof(T).IsAssignableFrom(self.GetType())) - return (T)(object)self; + if (typeof(T).IsAssignableFrom(self.Value.GetType())) + return (T)self.Value; try {