Skip to content

Commit fa77372

Browse files
authored
JObject.Merge does not work with object (#2201)
JamesNK/Newtonsoft.Json#2352 Newer versions of NewtonSoft.Json will throw "Could not determine JSON object type for type PuppeteerSharp.ViewPortOptions" Resolves #2199
1 parent f24c854 commit fa77372

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/PuppeteerSharp/ElementHandle.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,8 @@ public async Task<string> ScreenshotBase64Async(ScreenshotOptions options)
126126
if (viewport != null && (boundingBox.Width > viewport.Width || boundingBox.Height > viewport.Height))
127127
{
128128
var newRawViewport = JObject.FromObject(viewport);
129-
newRawViewport.Merge(new ViewPortOptions
130-
{
131-
Width = (int)Math.Max(viewport.Width, Math.Ceiling(boundingBox.Width)),
132-
Height = (int)Math.Max(viewport.Height, Math.Ceiling(boundingBox.Height)),
133-
});
129+
newRawViewport["Width"] = (int)Math.Max(viewport.Width, Math.Ceiling(boundingBox.Width));
130+
newRawViewport["Height"] = (int)Math.Max(viewport.Height, Math.Ceiling(boundingBox.Height));
134131
await Page.SetViewportAsync(newRawViewport.ToObject<ViewPortOptions>(true)).ConfigureAwait(false);
135132
needsViewportReset = true;
136133
}

0 commit comments

Comments
 (0)