diff --git a/AGENTS.md b/AGENTS.md index 14cb601..b962822 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -197,7 +197,6 @@ BenchmarkDotNet project (`net8.0`, `net10.0`), not part of the solution or the F - `ParseValidationBenchmark.cs`: `ParseDocument` including the validation walks, per document shape and DOCTYPE kind (none, internal subset, local external subset). - `TextContentBenchmark.cs`: `TextContent` of XML elements, from a single-text leaf to deep chains. - `Documents.cs`: the shared document shapes and their DTDs. -- `Compare-Builds.ps1`: measures the working tree against a baseline commit. ### Documentation @@ -331,17 +330,11 @@ dotnet run -c Release --project src/AngleSharp.Xml.Benchmarks -f net8.0 -- --che dotnet run -c Release --project src/AngleSharp.Xml.Benchmarks -f net8.0 -- --filter '*TextContent*' ``` -```powershell -./src/AngleSharp.Xml.Benchmarks/Compare-Builds.ps1 -BaselineRef [, ...] -AngleSharpVersion -Rounds 3 -Affinity -``` - -- Pass the same `-AngleSharpVersion` to every build when the compared commits default to different AngleSharp versions; otherwise core's own changes end up in the comparison. -- The script writes `summary.md` to its output directory: per case, each build's median of the rounds, its ratio to the working tree, the spread of the rounds, and the allocations. - -- `--check` runs every setup and benchmark body once without measuring. Run it on both builds before a long run; `Compare-Builds.ps1` does. -- Compare builds with `Compare-Builds.ps1`: two separately built copies, alternated round by round. BenchmarkDotNet rebuilds the benchmark project it finds from the current directory, so the script runs each build from its own source tree and fails a round whose logs name the other build's AngleSharp.Xml module. +- To compare two commits, build each from its own source tree and alternate them round by round, so drift over the run favours neither. BenchmarkDotNet rebuilds the benchmark project it finds from the current directory; every run prints the `// AngleSharp.Xml module` it measured, which shows that a round ran the intended build. +- Build every compared commit with the same `AngleSharpVersion` (an MSBuild property, also read from the environment) when they default to different AngleSharp versions; otherwise core's own changes end up in the comparison. +- `--check` runs every setup and benchmark body once without measuring. Run it on every build before a long run. - `MemoryDiagnoser` is on for every class; report the allocation column with the timings. -- Benchmarks need an otherwise idle machine; on hybrid CPUs pin them to the fast cores (`--affinity`, or `-Affinity` on the script). +- Benchmarks need an otherwise idle machine; on hybrid CPUs pin them to the fast cores (`--affinity`). - Keep the shapes within what the oldest compared build survives. Before the explicit-stack walks, the old code overflowed the call stack parsing at about 2600 levels with a DTD (2850 without) and in `TextContent` at about 5000 (net8.0, 1 MB stack), which is why the deep shapes stop at 2000 and 4000. - Every shape must stay valid against its DTD: an invalid document stops the walks at the first error and measures an early exit. `GlobalSetup` throws if one is not. - A parse allocates megabytes, so when the garbage collector runs during it can move a row by 5-10% either way, and the direction changes with the document size. That is why the catalog comes in three sizes (`catalog-500`, `catalog`, `catalog-2000`). A difference at one size alone is not proof. A change that really costs work shows at every size; one that flips sign between sizes is GC timing. To confirm, rerun with BenchmarkDotNet's `--envVars DOTNET_GCgen0size:20000000` (512 MB Gen0, so no Gen0 or Gen1 collection runs during a parse) and compare the work alone. diff --git a/CHANGELOG.md b/CHANGELOG.md index 346e068..3e989d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# 1.3.1 + +Released on Sunday, November 22 2026. + +- Fixed `document.title` of XHTML documents always being empty +- Fixed `createDocument` not being available to scripts (AngleSharp.Js) until a document was parsed +- Added running the scripts of the XHTML elements of a navigated XML document + # 1.3.0 Released on Sunday, November 1 2026. diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index bfa4d5c..8200409 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,6 +7,7 @@ AngleSharp.Xml contains code written by (in order of first pull request / commit * [Florian Rappl](https://github.com/FlorianRappl) * [Konstantin Safonov](https://github.com/kasthack) * [jbrayfaithlife](https://github.com/jbrayfaithlife) +* [Michael Thyregod](https://github.com/michaelthyregod) Without these awesome people AngleSharp.Xml could not exist. Thanks to everyone for your contributions! :beers: diff --git a/src/AngleSharp.Xml.Benchmarks/Compare-Builds.ps1 b/src/AngleSharp.Xml.Benchmarks/Compare-Builds.ps1 deleted file mode 100644 index bb620ed..0000000 --- a/src/AngleSharp.Xml.Benchmarks/Compare-Builds.ps1 +++ /dev/null @@ -1,239 +0,0 @@ -<# -.SYNOPSIS - Benchmarks the working tree against one or more baseline commits, rotating the builds round by round. - -.DESCRIPTION - Exports every baseline ref with git archive and copies this benchmark project into each, so all - builds run the same benchmark code against their own AngleSharp.Xml. Each build runs with - `dotnet run` from inside its own source tree: BenchmarkDotNet rebuilds the benchmark project - it finds from the current directory, so running every build from one tree would measure one - library several times. Every setup writes the module id of the AngleSharp.Xml it loaded, and - each round fails if a build's logs name another build's library, or none. - - Before measuring, --check runs every benchmark's setup and body once on every build. Each round - starts with a different build, so drift over the run does not favour one; each round keeps - BenchmarkDotNet's results apart under the output directory, and summary.md compares the - median of the rounds per case. On Windows the machine is kept awake for the whole run. - - Benchmarks need an otherwise idle machine. Pin them to fast, homogeneous cores with -Affinity - on hybrid CPUs. - -.EXAMPLE - ./Compare-Builds.ps1 -BaselineRef e314d1b -BuildOnly - ./Compare-Builds.ps1 -BaselineRef e314d1b, 771dafb -Rounds 3 -Affinity -Filter '*TextContent*' -#> -[CmdletBinding()] -param( - # The commits the working tree is compared against. - [String[]] $BaselineRef = @('HEAD'), - [Int32] $Rounds = 3, - [String[]] $Filter = @('*'), - [String] $Framework = 'net8.0', - # AngleSharp package version for every build; empty keeps each project's default. - [String] $AngleSharpVersion = '', - # BenchmarkDotNet --affinity mask; empty runs unpinned. - [String] $Affinity = '', - [String] $OutputDirectory = (Join-Path ([IO.Path]::GetTempPath()) ('anglesharp-xml-benchmarks-' + (Get-Date -Format 'yyyyMMdd-HHmmss'))), - # Build every copy and run --check, without measuring. - [Switch] $BuildOnly -) - -$ErrorActionPreference = 'Stop' -$repository = (git -C $PSScriptRoot rev-parse --show-toplevel).Trim() -$benchmarkProject = 'src/AngleSharp.Xml.Benchmarks' -$markerPattern = '// AngleSharp\.Xml module ([0-9a-f-]{36})' -$currentBenchmarks = Join-Path $repository $benchmarkProject - -New-Item -ItemType Directory -Force $OutputDirectory | Out-Null - -$projects = [ordered]@{} - -# Baselines: each ref's sources plus the current benchmark project -foreach ($ref in $BaselineRef) { - $name = 'baseline-' + ($ref -replace '[^A-Za-z0-9._-]', '_') - $source = Join-Path $OutputDirectory "$name-source" - New-Item -ItemType Directory -Force $source | Out-Null - $archive = Join-Path $OutputDirectory "$name.tar" - git -C $repository archive --format=tar -o $archive $ref src - if ($LASTEXITCODE -ne 0) { throw "git archive of $ref failed." } - tar -xf $archive -C $source - Remove-Item $archive - - $benchmarks = Join-Path $source $benchmarkProject - Remove-Item $benchmarks -Recurse -Force -ErrorAction SilentlyContinue - Get-ChildItem $currentBenchmarks -Recurse -File | - Where-Object { $_.FullName.Substring($currentBenchmarks.Length) -notmatch '[\\/](bin|obj|BenchmarkDotNet\.Artifacts)[\\/]' } | - ForEach-Object { - $target = Join-Path $benchmarks $_.FullName.Substring($currentBenchmarks.Length) - New-Item -ItemType Directory -Force (Split-Path $target) | Out-Null - Copy-Item $_.FullName $target - } - - $projects[$name] = $benchmarks -} - -$projects['candidate'] = $currentBenchmarks -$names = @($projects.Keys) -$modules = @{} - -# MSBuild reads environment variables as properties, so this also reaches the project -# BenchmarkDotNet generates and builds for every benchmark run -$previousAngleSharpVersion = $env:AngleSharpVersion -if ($AngleSharpVersion) { $env:AngleSharpVersion = $AngleSharpVersion } - -function Invoke-Benchmarks([String] $name, [String[]] $arguments) { - Push-Location $projects[$name] - try { - $output = dotnet run -c Release -f $Framework -- @arguments 2>&1 | ForEach-Object { Write-Host $_; "$_" } - if ($LASTEXITCODE -ne 0) { throw "The $name build failed: dotnet run $($arguments -join ' ') (exit code $LASTEXITCODE)." } - return $output - } - finally { - Pop-Location - } -} - -function Format-Time([Double] $nanoseconds) { - if ($nanoseconds -ge 1e6) { return '{0:N2} ms' -f ($nanoseconds / 1e6) } - if ($nanoseconds -ge 1e3) { return '{0:N2} us' -f ($nanoseconds / 1e3) } - return '{0:N1} ns' -f $nanoseconds -} - -function Get-Median([Double[]] $values) { - $sorted = $values | Sort-Object - return $sorted[[Int32][Math]::Floor($sorted.Count / 2)] -} - -# BenchmarkDotNet writes the unit into each CSV cell and picks it per row ("952.654 μs", -# "1,280.41 KB"), with invariant separators, so each value is converted to ns or B -$timeUnits = @{ 'ns' = 1.0; 'us' = 1e3; 'ms' = 1e6; 's' = 1e9 } -$sizeUnits = @{ 'B' = 1.0; 'KB' = 1024.0; 'MB' = 1048576.0; 'GB' = 1073741824.0 } - -function ConvertFrom-Cell([String] $cell, [Hashtable] $units) { - # Microseconds come as the Greek mu or the micro sign, which hashtable keys cannot tell apart - $text = $cell.Trim().Replace([Char]0x03BC, 'u').Replace([Char]0x00B5, 'u') - - # A failed benchmark reports NA; a row without allocations can report - - if ($text -eq 'NA') { return [Double]::NaN } - if ($text -eq '-') { return 0.0 } - - if ($text -notmatch '^(?[\d,]*\.?\d+)\s*(?\S+)$' -or -not $units.ContainsKey($Matches.unit)) { - throw "Cannot read the value '$cell' from the BenchmarkDotNet report." - } - - return [Double]::Parse(($Matches.value -replace ',', ''), [Globalization.CultureInfo]::InvariantCulture) * $units[$Matches.unit] -} - -function Write-Summary { - # Only this run's rounds: the baseline source trees live in the output directory too, and - # a report BenchmarkDotNet left in one of them would otherwise count as a build - $reports = Get-ChildItem $OutputDirectory -Directory -Filter 'round-*' | ForEach-Object { Get-ChildItem $_.FullName -Recurse -Filter *-report.csv } - $rows = foreach ($csv in $reports) { - $build = $csv.Directory.Parent.Name - - foreach ($row in Import-Csv $csv.FullName) { - # A joined run writes ? for a parameter the benchmark class does not have - $parameters = @($row.PSObject.Properties | Where-Object { $_.Name -in @('Shape', 'Doctype') -and $_.Value -and $_.Value -ne '?' } | ForEach-Object Value) -join ' ' - [PSCustomObject]@{ - Build = $build - Case = ("$($row.Type -replace 'Benchmark$', '') $parameters").Trim() - Mean = ConvertFrom-Cell $row.Mean $timeUnits - Allocated = ConvertFrom-Cell $row.Allocated $sizeUnits - } - } - } - - # A failed benchmark has no mean to compare - $rows = @($rows | Where-Object { -not [Double]::IsNaN($_.Mean) }) - - $lines = @( - "# Benchmark comparison", - "", - "Median of $Rounds rounds per build; ratio = build / candidate; spread = (max - min) / median of the rounds.", - "", - ("| Case | " + (($names | ForEach-Object { "$_ | ratio | spread | allocated" }) -join ' | ') + " |"), - ("|---|" + (($names | ForEach-Object { '---:|---:|---:|---:' }) -join '|') + "|") - ) - - foreach ($case in $rows | Select-Object -ExpandProperty Case -Unique) { - $candidate = Get-Median @($rows | Where-Object { $_.Case -eq $case -and $_.Build -eq 'candidate' } | ForEach-Object Mean) - $cells = foreach ($name in $names) { - $measured = @($rows | Where-Object { $_.Case -eq $case -and $_.Build -eq $name }) - $median = Get-Median @($measured | ForEach-Object Mean) - $spread = (($measured.Mean | Measure-Object -Maximum).Maximum - ($measured.Mean | Measure-Object -Minimum).Minimum) / $median * 100 - '{0} | {1:N3} | {2:N1}% | {3:N0} B' -f (Format-Time $median), ($median / $candidate), $spread, (Get-Median @($measured | ForEach-Object Allocated)) - } - - $lines += "| $case | " + ($cells -join ' | ') + " |" - } - - $summary = Join-Path $OutputDirectory 'summary.md' - Set-Content $summary $lines - Write-Host "Summary in $summary" -} - -$keepAwake = $IsWindows -or $env:OS -eq 'Windows_NT' - -try { - foreach ($name in $names) { - Write-Host "Building and checking $name ..." - $output = Invoke-Benchmarks $name @('--check') - $match = $output | Select-String $markerPattern | Select-Object -First 1 - if (-not $match) { throw "The $name --check output names no AngleSharp.Xml module." } - $modules[$name] = $match.Matches[0].Groups[1].Value - Write-Host "$name measures AngleSharp.Xml module $($modules[$name])" - } - - foreach ($name in $names) { - $same = @($names | Where-Object { $_ -ne $name -and $modules[$_] -eq $modules[$name] }) - if ($same) { throw "$name and $($same -join ', ') load the same AngleSharp.Xml module ($($modules[$name])); there is nothing to compare." } - } - - if ($BuildOnly) { - Write-Host "Built and checked every copy under $OutputDirectory" - return - } - - if ($keepAwake) { - Add-Type -Namespace Benchmarks -Name Power -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint flags);' - # ES_CONTINUOUS | ES_SYSTEM_REQUIRED - [Benchmarks.Power]::SetThreadExecutionState([uint32]'0x80000001') | Out-Null - } - - for ($round = 1; $round -le $Rounds; $round++) { - # Rotate who goes first, so drift over the run does not favour one build - $order = for ($i = 0; $i -lt $names.Count; $i++) { $names[($i + $round - 1) % $names.Count] } - - foreach ($name in $order) { - $artifacts = Join-Path $OutputDirectory "round-$round/$name" - $arguments = @('--filter') + $Filter + @('--artifacts', $artifacts, '--join') - - if ($Affinity) { - $arguments += @('--affinity', $Affinity) - } - - Write-Host "Round $round of ${Rounds}: $name" - Invoke-Benchmarks $name $arguments | Out-Null - - # Prove from the logs which library this run measured - $seen = @(Get-ChildItem $artifacts -Recurse -Filter *.log | Select-String $markerPattern | ForEach-Object { $_.Matches[0].Groups[1].Value } | Sort-Object -Unique) - - if (-not $seen) { throw "Round $round of ${name}: the logs name no AngleSharp.Xml module." } - - foreach ($other in $names | Where-Object { $_ -ne $name }) { - if ($seen -contains $modules[$other]) { throw "Round $round of ${name} measured the $other build's AngleSharp.Xml ($($modules[$other]))." } - } - } - } - - Write-Summary - Write-Host "Results under $OutputDirectory (round-N//results)" -} -finally { - if ($keepAwake -and ('Benchmarks.Power' -as [Type])) { - # ES_CONTINUOUS alone clears the request - [Benchmarks.Power]::SetThreadExecutionState([uint32]'0x80000000') | Out-Null - } - - $env:AngleSharpVersion = $previousAngleSharpVersion -} diff --git a/src/AngleSharp.Xml.Docs/package.json b/src/AngleSharp.Xml.Docs/package.json index 0844920..ff8e22d 100644 --- a/src/AngleSharp.Xml.Docs/package.json +++ b/src/AngleSharp.Xml.Docs/package.json @@ -1,6 +1,6 @@ { "name": "@anglesharp/xml", - "version": "1.3.0", + "version": "1.3.1", "preview": true, "description": "The doclet for the AngleSharp.Xml documentation.", "keywords": [ diff --git a/src/AngleSharp.Xml.Tests/Dom/Acid3Tests.cs b/src/AngleSharp.Xml.Tests/Dom/Acid3Tests.cs new file mode 100644 index 0000000..76c7819 --- /dev/null +++ b/src/AngleSharp.Xml.Tests/Dom/Acid3Tests.cs @@ -0,0 +1,68 @@ +namespace AngleSharp.Xml.Tests.Dom +{ + using AngleSharp.Dom; + using AngleSharp.Io; + using AngleSharp.Xml.Parser; + using NUnit.Framework; + using System; + using System.Linq; + using System.Threading.Tasks; + + /// + /// Behavior the Acid3 test (acid3.acidtests.org) relies on. + /// + [TestFixture] + public class Acid3Tests + { + private const String XhtmlNamespace = "http://www.w3.org/1999/xhtml"; + + [Test] + public void TitleOfAnXhtmlDocumentUpdatesWithItsElement() + { + var document = BrowsingContext.New(Configuration.Default.WithXml()).OpenNewAsync().Result; + var doctype = document.Implementation.CreateDocumentType("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"); + var xhtml = document.Implementation.CreateDocument(XhtmlNamespace, "html", doctype); + xhtml.DocumentElement.AppendChild(xhtml.CreateElement(XhtmlNamespace, "head")); + xhtml.DocumentElement.AppendChild(xhtml.CreateElement(XhtmlNamespace, "body")); + var title = xhtml.CreateElement(XhtmlNamespace, "title"); + xhtml.DocumentElement.FirstChild.AppendChild(title); + + Assert.AreEqual(String.Empty, xhtml.Title); + + title.TextContent = " Sparrow "; + + Assert.AreEqual("Sparrow", xhtml.Title); + } + + [Test] + public async Task DocumentThatIsNotWellFormedFailsToOpen() + { + // showing the error instead is up to the application (IDocumentErrorHandler) + var context = BrowsingContext.New(Configuration.Default.WithXml()); + + try + { + await context.OpenAsync(res => res + .Address("http://localhost/xhtml.2") + .Content("

Parsing Test

") + .Header(HeaderNames.ContentType, MimeTypeNames.Xml)); + Assert.Fail("The parse error should propagate."); + } + catch (XmlParseException) + { + } + } + + [Test] + public void ConfigurationNamesTheLibrarySoItsDomExtensionsAreFound() + { + var config = Configuration.Default.WithXml().WithXml(); + var libraries = config.Services + .Where(m => m is not Delegate) + .Select(m => m.GetType().Assembly) + .Count(m => m == typeof(XmlParser).Assembly); + + Assert.AreEqual(1, libraries); + } + } +} diff --git a/src/AngleSharp.Xml/Dom/Internal/XmlDocument.cs b/src/AngleSharp.Xml/Dom/Internal/XmlDocument.cs index 223728f..95c7ae7 100644 --- a/src/AngleSharp.Xml/Dom/Internal/XmlDocument.cs +++ b/src/AngleSharp.Xml/Dom/Internal/XmlDocument.cs @@ -1,9 +1,11 @@ namespace AngleSharp.Xml.Dom { using AngleSharp.Dom; + using AngleSharp.Html.Dom; using AngleSharp.Io; using AngleSharp.Text; using System; + using System.Linq; /// /// Represents a document node that contains only XML nodes. @@ -72,8 +74,23 @@ public override Node Clone(Document owner, Boolean deep) #region Helpers + /// + /// The title of an XHTML document is its first title element (in the HTML namespace). + /// + protected override String GetTitle() + { + var title = DocumentElement?.Descendants().FirstOrDefault(); + return title?.TextContent.CollapseAndStrip() ?? base.GetTitle(); + } + protected override void SetTitle(String value) { + var title = DocumentElement?.Descendants().FirstOrDefault(); + + if (title is not null) + { + title.TextContent = value ?? String.Empty; + } } internal void SetValidity(Boolean isValid) diff --git a/src/AngleSharp.Xml/XmlConfigurationExtensions.cs b/src/AngleSharp.Xml/XmlConfigurationExtensions.cs index 7fa840d..8e1e1da 100644 --- a/src/AngleSharp.Xml/XmlConfigurationExtensions.cs +++ b/src/AngleSharp.Xml/XmlConfigurationExtensions.cs @@ -1,8 +1,12 @@ namespace AngleSharp { + using AngleSharp.Browser; using AngleSharp.Dom; + using AngleSharp.Html.Dom; using AngleSharp.Io; + using AngleSharp.Scripting; using AngleSharp.Svg.Dom; + using AngleSharp.Text; using AngleSharp.Xml.Dom; using AngleSharp.Xml.Parser; using System; @@ -34,25 +38,86 @@ public static IConfiguration WithXml(this IConfiguration configuration) documentFactory.Register(MimeTypeNames.Svg, LoadSvgAsync); } + // AngleSharp.Js exposes the DOM extensions of the libraries it finds services of, but + // only sees the parser once it was created (e.g. createDocument would be missing) + if (!configuration.Services.OfType().Any()) + { + configuration = configuration.With(XmlLibrary.Instance); + } + return configuration.WithOnly(ctx => new XmlParser(ctx)); } + /// + /// Marks a configuration as using this library. + /// + private sealed class XmlLibrary + { + public static readonly XmlLibrary Instance = new XmlLibrary(); + } + private static Task LoadXmlAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancellationToken) { - var parser = context.GetService() ?? throw new InvalidOperationException("The IXmlParser service has been removed. Cannot continue."); var document = new XmlDocument(context, options.Source); - document.Setup(options.Response, options.ContentType, options.ImportAncestor); - context.NavigateTo(document); - return parser.ParseDocumentAsync(document, cancellationToken); + return LoadAsync(context, document, options, cancellationToken); } private static Task LoadSvgAsync(IBrowsingContext context, CreateDocumentOptions options, CancellationToken cancellationToken) { - var parser = context.GetService() ?? throw new InvalidOperationException("The IXmlParser service has been removed. Cannot continue."); var document = new SvgDocument(context, options.Source); + return LoadAsync(context, document, options, cancellationToken); + } + + private static async Task LoadAsync(IBrowsingContext context, Document document, CreateDocumentOptions options, CancellationToken cancellationToken) + { + var parser = context.GetService() ?? throw new InvalidOperationException("The IXmlParser service has been removed. Cannot continue."); document.Setup(options.Response, options.ContentType, options.ImportAncestor); context.NavigateTo(document); - return parser.ParseDocumentAsync(document, cancellationToken); + + await parser.ParseDocumentAsync(document, cancellationToken).ConfigureAwait(false); + await RunScriptsAsync(context, document, cancellationToken).ConfigureAwait(false); + return document; + } + + /// + /// Runs the (inline) scripts of the XHTML elements of a document that was navigated to, + /// in tree order once it has been parsed. + /// + private static async Task RunScriptsAsync(IBrowsingContext context, Document document, CancellationToken cancellationToken) + { + if (!context.IsScripting()) + { + return; + } + + var loop = context.GetService(); + // the parser creates its own elements, so they are found by their name + var scripts = document.Descendants() + .Where(m => m.LocalName.Is("script") && m.NamespaceUri.Is(NamespaceNames.HtmlUri) && !m.HasAttribute("src")) + .ToArray(); + + foreach (var script in scripts) + { + var type = script.GetAttribute("type"); + var service = context.GetScripting(String.IsNullOrEmpty(type) ? MimeTypeNames.DefaultJavaScript : type); + + if (service is null || script.Parent is null) + { + continue; + } + + var response = VirtualResponse.Create(r => r.Address(document.DocumentUri).Content(script.TextContent ?? String.Empty)); + + try + { + await service.EvaluateScriptAsync(response, new ScriptOptions(document, loop) { Element = script as IHtmlScriptElement }, cancellationToken).ConfigureAwait(false); + } + catch (Exception ex) when (ex is not OperationCanceledException) + { + // a failing script doesn't stop the others + System.Diagnostics.Debug.WriteLine(ex); + } + } } } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 96fd140..3827f2d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ Adds a powerful XML and DTD parser to AngleSharp. AngleSharp.Xml - 1.3.0 + 1.3.1 latest true true