Skip to content

Commit 3f92775

Browse files
committed
move function around to make more obvious goes with getDomNode, add missing return type for getDomNode
1 parent ee2dcab commit 3f92775

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/AutomateBrowser.cls

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -762,10 +762,9 @@ Public Function getNodeIdOrName(ByVal node As cdpDOMNode) As String
762762
getNodeIdOrName = idOrName
763763
End Function
764764

765-
766765
' takes a nodeId or backendNodeId (or RemoteObject.objectId) and returns cdpDOMNode object
767766
Public Function getDomNode(Optional ByVal nodeId As Integer = 0, Optional ByVal backendNodeId As Integer = 0, Optional ByVal objectId As String = vbNullString, _
768-
Optional ByVal depth As Integer = -1, Optional ByVal pierce As Boolean = False)
767+
Optional ByVal depth As Integer = -1, Optional ByVal pierce As Boolean = False) As cdpDOMNode
769768
Dim dict As Dictionary
770769
If objectId <> vbNullString Then
771770
Set dict = cdp.DOM.describeNode(objectId:=objectId, depth:=depth, pierce:=pierce)
@@ -782,6 +781,11 @@ Public Function getDomNode(Optional ByVal nodeId As Integer = 0, Optional ByVal
782781
End If
783782
End Function
784783

784+
' converts a Runtime.RemoteObject into a DOM.Node
785+
Public Function RemoteObjectToDomNode(ByVal remoteObj As cdpRuntimeRemoteObject, Optional ByVal depth As Integer = -1, Optional ByVal pierce As Boolean = False) As cdpDOMNode
786+
Set RemoteObjectToDomNode = getDomNode(objectId:=remoteObj.objectId, depth:=depth, pierce:=pierce)
787+
End Function
788+
785789
' takes a Collection of nodeIds and returns a Dictionary of cdpDomNode objetcs
786790
' Note: resulting dictionary is keyed on id if node has one, else name if has one, else a unique numerical value
787791
Public Function getDomNodes(Optional ByVal nodeIds As Collection, Optional ByVal backendNodeIds As Collection, Optional objectIds As Collection, Optional ByVal remoteNodeList As cdpRuntimeRemoteObject, _
@@ -844,11 +848,6 @@ Public Function getDomNodes(Optional ByVal nodeIds As Collection, Optional ByVal
844848
Set getDomNodes = nodes
845849
End Function
846850

847-
' converts a Runtime.RemoteObject into a DOM.Node
848-
Public Function RemoteObjectToDomNode(ByVal remoteObj As cdpRuntimeRemoteObject, Optional ByVal depth As Integer = -1, Optional ByVal pierce As Boolean = False) As cdpDOMNode
849-
Set RemoteObjectToDomNode = getDomNode(objectId:=remoteObj.objectId, depth:=depth, pierce:=pierce)
850-
End Function
851-
852851
' internally to support getting elements in iframes, we have to run
853852
' javascript relative to the frame, for nonframe elements we can just call cdp.DOM.querySelector
854853
' This compiles a javascript function that does that.

0 commit comments

Comments
 (0)