Skip to content

Commit 551f1d3

Browse files
authored
Merge pull request #95 from lahma/jint-3.1.0
Upgrade to Jint 3.1.0
2 parents e8de221 + 37d4fa3 commit 551f1d3

7 files changed

+32
-47
lines changed

src/AngleSharp.Js.Tests/AngleSharp.Js.Tests.csproj

-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<RootNamespace>AngleSharp.Js.Tests</RootNamespace>
43
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">net6.0;net7.0;net8.0</TargetFrameworks>
54
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net462;net472;net6.0;net7.0;net8.0</TargetFrameworks>
6-
<SignAssembly>true</SignAssembly>
7-
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
85
<IsPackable>false</IsPackable>
9-
<LangVersion>7.1</LangVersion>
10-
<AssemblyName>AngleSharp.Js.Tests</AssemblyName>
116
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <!-- https://github.com/Tyrrrz/GitHubActionsTestLogger/issues/5 -->
127
</PropertyGroup>
138

src/AngleSharp.Js.Tests/Mocks/MockHttpClientRequester.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public MockHttpClientRequester(Dictionary<string, string> mockResponses) : base(
2121
_mockResponses = mockResponses;
2222
}
2323

24-
protected override async Task<IResponse> PerformRequestAsync(Request request, CancellationToken cancel)
24+
protected override Task<IResponse> PerformRequestAsync(Request request, CancellationToken cancel)
2525
{
2626
var response = new DefaultResponse();
2727

@@ -36,7 +36,7 @@ protected override async Task<IResponse> PerformRequestAsync(Request request, Ca
3636
response.Content = new MemoryStream(Encoding.UTF8.GetBytes(string.Empty));
3737
}
3838

39-
return response;
39+
return Task.FromResult<IResponse>(response);
4040
}
4141
}
4242
}

src/AngleSharp.Js/AngleSharp.Js.csproj

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<AssemblyName>AngleSharp.Js</AssemblyName>
4-
<RootNamespace>AngleSharp.Js</RootNamespace>
5-
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
6-
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard2.0;net462;net472;net6.0;net7.0;net8.0</TargetFrameworks>
7-
<SignAssembly>true</SignAssembly>
8-
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
3+
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0</TargetFrameworks>
4+
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">$(TargetFrameworks);net462;net472</TargetFrameworks>
95
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10-
<LangVersion>7.1</LangVersion>
116
<RepositoryUrl>https://github.com/AngleSharp/AngleSharp.Js</RepositoryUrl>
127
<RepositoryType>git</RepositoryType>
138
<PublishRepositoryUrl>true</PublishRepositoryUrl>
149
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1510
<IncludeSymbols>true</IncludeSymbols>
1611
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
12+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1713
</PropertyGroup>
1814

1915
<ItemGroup>
20-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
16+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
2117
</ItemGroup>
2218

2319
<ItemGroup>
24-
<PackageReference Include="AngleSharp" Version="1.1.0" />
25-
<PackageReference Include="Jint" Version="3.0.1" />
20+
<PackageReference Include="AngleSharp" Version="1.1.2" />
21+
<PackageReference Include="Jint" Version="3.1.0" />
2622
</ItemGroup>
2723

2824
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">

src/AngleSharp.Js/Extensions/EngineExtensions.cs

+10-13
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,18 @@ private static JsValue[] ExpandInitDict(JsValue[] arguments, ParameterInfo[] par
148148
newArgs[i] = arguments[i];
149149
}
150150

151-
if (obj != null)
151+
for (var i = end + offset; i < max; i++)
152152
{
153-
for (var i = end + offset; i < max; i++)
154-
{
155-
var p = parameters[i];
156-
var name = p.Name;
153+
var p = parameters[i];
154+
var name = p.Name;
157155

158-
if (obj.HasProperty(name))
159-
{
160-
newArgs[i - offset] = obj.GetProperty(name).Value;
161-
}
162-
else
163-
{
164-
newArgs[i - offset] = JsValue.Undefined;
165-
}
156+
if (obj.HasProperty(name))
157+
{
158+
newArgs[i - offset] = obj.Get(name);
159+
}
160+
else
161+
{
162+
newArgs[i - offset] = JsValue.Undefined;
166163
}
167164
}
168165

src/AngleSharp.Js/Proxies/DomNodeInstance.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ public override PropertyDescriptor GetOwnProperty(JsValue property)
3232
{
3333
return descriptor;
3434
}
35-
else if (prototype.HasProperty(property))
35+
36+
var prototypeProperty = prototype.GetOwnProperty(property);
37+
if (prototypeProperty != PropertyDescriptor.Undefined)
3638
{
37-
return prototype.GetProperty(property);
39+
return prototypeProperty;
3840
}
3941
}
4042

src/AngleSharp.Js/Proxies/DomPrototypeInstance.cs

+9-15
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
namespace AngleSharp.Js
22
{
33
using AngleSharp.Attributes;
4-
using AngleSharp.Dom;
54
using AngleSharp.Text;
6-
using Jint.Native;
75
using Jint.Native.Object;
86
using Jint.Native.Symbol;
97
using Jint.Runtime.Descriptors;
@@ -55,7 +53,7 @@ public Boolean TryGetFromIndex(Object value, String index, out PropertyDescripto
5553
{
5654
if (ex.InnerException is ArgumentOutOfRangeException)
5755
{
58-
result = new PropertyDescriptor(JsValue.Undefined, false, false, false);
56+
result = PropertyDescriptor.Undefined;
5957
return true;
6058
}
6159

@@ -104,12 +102,9 @@ private void SetNormalEvents(IEnumerable<EventInfo> eventInfos)
104102
{
105103
foreach (var eventInfo in eventInfos)
106104
{
107-
var names = eventInfo.GetCustomAttributes<DomNameAttribute>()
108-
.Select(m => m.OfficialName);
109-
110-
foreach (var name in names)
105+
foreach (var m in eventInfo.GetCustomAttributes<DomNameAttribute>())
111106
{
112-
SetEvent(name, eventInfo.AddMethod, eventInfo.RemoveMethod);
107+
SetEvent(m.OfficialName, eventInfo.AddMethod, eventInfo.RemoveMethod);
113108
}
114109
}
115110
}
@@ -123,6 +118,7 @@ private void SetExtensionMethods(IEnumerable<MethodInfo> methods)
123118

124119
if (HasProperty(name))
125120
{
121+
// skip
126122
}
127123
else if (value.Adder != null && value.Remover != null)
128124
{
@@ -148,9 +144,10 @@ private void SetNormalProperties(IEnumerable<PropertyInfo> properties)
148144
var putsForward = property.GetCustomAttribute<DomPutForwardsAttribute>();
149145
var names = property
150146
.GetCustomAttributes<DomNameAttribute>()
151-
.Select(m => m.OfficialName);
147+
.Select(m => m.OfficialName)
148+
.ToArray();
152149

153-
if (index != null || names.Any(m => m.Is("item")))
150+
if (index != null || Array.Exists(names, m => m.Is("item")))
154151
{
155152
SetIndexer(property, indexParameters);
156153
}
@@ -166,12 +163,9 @@ private void SetNormalMethods(IEnumerable<MethodInfo> methods)
166163
{
167164
foreach (var method in methods)
168165
{
169-
var names = method.GetCustomAttributes<DomNameAttribute>()
170-
.Select(m => m.OfficialName);
171-
172-
foreach (var name in names)
166+
foreach (var m in method.GetCustomAttributes<DomNameAttribute>())
173167
{
174-
SetMethod(name, method);
168+
SetMethod(m.OfficialName, method);
175169
}
176170
}
177171
}

src/Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Version>1.0.0</Version>
66
<LangVersion>latest</LangVersion>
77
<SignAssembly>true</SignAssembly>
8+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
89
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\Key.snk</AssemblyOriginatorKeyFile>
910
</PropertyGroup>
1011
</Project>

0 commit comments

Comments
 (0)