github.com/MontFerret/ferret@v0.18.0/pkg/drivers/cdp/templates/children.go (about)

     1  package templates
     2  
     3  import (
     4  	"github.com/mafredri/cdp/protocol/runtime"
     5  
     6  	"github.com/MontFerret/ferret/pkg/drivers/cdp/eval"
     7  	"github.com/MontFerret/ferret/pkg/runtime/values"
     8  )
     9  
    10  const getChildren = "(el) => Array.from(el.children)"
    11  
    12  func GetChildren(id runtime.RemoteObjectID) *eval.Function {
    13  	return eval.F(getChildren).WithArgRef(id)
    14  }
    15  
    16  const getChildrenCount = "(el) => el.children.length"
    17  
    18  func GetChildrenCount(id runtime.RemoteObjectID) *eval.Function {
    19  	return eval.F(getChildrenCount).WithArgRef(id)
    20  }
    21  
    22  const getChildByIndex = "(el, idx) => el.children[idx]"
    23  
    24  func GetChildByIndex(id runtime.RemoteObjectID, index values.Int) *eval.Function {
    25  	return eval.F(getChildByIndex).WithArgRef(id).WithArgValue(index)
    26  }