github.com/MontFerret/ferret@v0.18.0/pkg/stdlib/html/elements.go (about) 1 package html 2 3 import ( 4 "context" 5 6 "github.com/MontFerret/ferret/pkg/runtime/core" 7 "github.com/MontFerret/ferret/pkg/runtime/values" 8 ) 9 10 // ELEMENTS finds HTML elements by a given CSS selector. 11 // Returns an empty array if element not found. 12 // @param {HTMLPage | HTMLDocument | HTMLElement} node - Target html node. 13 // @param {String} selector - CSS selector. 14 // @return {HTMLElement[]} - An array of matched HTML elements. 15 func Elements(ctx context.Context, args ...core.Value) (core.Value, error) { 16 el, selector, err := queryArgs(args) 17 18 if err != nil { 19 return values.None, err 20 } 21 22 return el.QuerySelectorAll(ctx, selector) 23 }