Skip to content

Commit 1459dbe

Browse files
authored
Refactor ElementHandle (#2850)
* Refactor ElementHandle * roll docs to .net 9 * it's net 8 * Assign before using
1 parent e1b7456 commit 1459dbe

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

.github/workflows/on-push-do-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- name: Setup .NET
1010
uses: actions/setup-dotnet@v3
1111
with:
12-
dotnet-version: 7.0.x
12+
dotnet-version: 8.0.x
1313
- name: Run MarkdownSnippets
1414
run: |
1515
dotnet tool install --global MarkdownSnippets.Tool

lib/PuppeteerSharp/Cdp/CdpElementHandle.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ public class CdpElementHandle : ElementHandle
3737

3838
internal CdpElementHandle(
3939
IsolatedWorld world,
40-
RemoteObject remoteObject) : base(world, remoteObject)
40+
RemoteObject remoteObject)
4141
{
4242
Handle = new CdpJSHandle(world, remoteObject);
4343
Logger = Realm.Environment.Client.Connection.LoggerFactory.CreateLogger(GetType());
4444
_cdpFrame = Realm.Frame as CdpFrame;
4545
}
4646

47+
/// <inheritdoc />
48+
public override RemoteObject RemoteObject => Handle.RemoteObject;
49+
50+
internal override IsolatedWorld Realm => Handle.Realm;
51+
4752
/// <summary>
4853
/// Logger.
4954
/// </summary>

lib/PuppeteerSharp/Cdp/CdpJSHandle.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,18 @@ namespace PuppeteerSharp.Cdp;
3131
/// <inheritdoc/>
3232
public class CdpJSHandle : JSHandle
3333
{
34-
internal CdpJSHandle(IsolatedWorld world, RemoteObject remoteObject) : base(world, remoteObject)
34+
internal CdpJSHandle(IsolatedWorld world, RemoteObject remoteObject)
3535
{
36+
Realm = world;
37+
RemoteObject = remoteObject;
3638
Logger = Client.Connection.LoggerFactory.CreateLogger(GetType());
3739
}
3840

41+
/// <inheritdoc/>
42+
public override RemoteObject RemoteObject { get; }
43+
44+
internal override IsolatedWorld Realm { get; }
45+
3946
/// <summary>
4047
/// Logger.
4148
/// </summary>

lib/PuppeteerSharp/ElementHandle.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ public abstract class ElementHandle : JSHandle, IElementHandle
1919
{
2020
private ElementHandle _isolatedHandle;
2121

22-
internal ElementHandle(
23-
IsolatedWorld world,
24-
RemoteObject remoteObject) : base(world, remoteObject)
22+
internal ElementHandle()
2523
{
2624
}
2725

lib/PuppeteerSharp/JSHandle.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,19 @@ namespace PuppeteerSharp
99
/// <inheritdoc/>
1010
public abstract class JSHandle : IJSHandle
1111
{
12-
internal JSHandle(IsolatedWorld world, RemoteObject remoteObject)
12+
internal JSHandle()
1313
{
14-
Realm = world;
15-
RemoteObject = remoteObject;
1614
}
1715

1816
/// <inheritdoc/>
1917
public bool Disposed { get; protected set; }
2018

2119
/// <inheritdoc/>
22-
public RemoteObject RemoteObject { get; }
20+
public abstract RemoteObject RemoteObject { get; }
2321

2422
internal Func<Task> DisposeAction { get; set; }
2523

26-
internal IsolatedWorld Realm { get; }
24+
internal abstract IsolatedWorld Realm { get; }
2725

2826
internal Frame Frame => Realm.Environment as Frame;
2927

0 commit comments

Comments
 (0)