github.com/MontFerret/ferret@v0.18.0/pkg/drivers/common/frames.go (about) 1 package common 2 3 import ( 4 "context" 5 6 "github.com/MontFerret/ferret/pkg/drivers" 7 "github.com/MontFerret/ferret/pkg/runtime/core" 8 "github.com/MontFerret/ferret/pkg/runtime/values" 9 ) 10 11 func CollectFrames(ctx context.Context, receiver *values.Array, doc drivers.HTMLDocument) error { 12 receiver.Push(doc) 13 14 children, err := doc.GetChildDocuments(ctx) 15 16 if err != nil { 17 return err 18 } 19 20 children.ForEach(func(value core.Value, idx int) bool { 21 childDoc, ok := value.(drivers.HTMLDocument) 22 23 if !ok { 24 err = core.TypeError(value.Type(), drivers.HTMLDocumentType) 25 26 return false 27 } 28 29 return CollectFrames(ctx, receiver, childDoc) == nil 30 }) 31 32 return nil 33 }