github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/goquery/expand.go (about) 1 package goquery 2 3 import ( 4 "code.google.com/p/go.net/html" 5 ) 6 7 // Add() adds the selector string's matching nodes to those in the current 8 // selection and returns a new Selection object. 9 // The selector string is run in the context of the document of the current 10 // Selection object. 11 func (this *Selection) Add(selector string) *Selection { 12 return this.AddNodes(findWithSelector([]*html.Node{this.document.rootNode}, selector)...) 13 } 14 15 // AddSelection() adds the specified Selection object's nodes to those in the 16 // current selection and returns a new Selection object. 17 func (this *Selection) AddSelection(sel *Selection) *Selection { 18 if sel == nil { 19 return this.AddNodes() 20 } 21 return this.AddNodes(sel.Nodes...) 22 } 23 24 // Union() is an alias for AddSelection(). 25 func (this *Selection) Union(sel *Selection) *Selection { 26 return this.AddSelection(sel) 27 } 28 29 // AddNodes() adds the specified nodes to those in the 30 // current selection and returns a new Selection object. 31 func (this *Selection) AddNodes(nodes ...*html.Node) *Selection { 32 return pushStack(this, appendWithoutDuplicates(this.Nodes, nodes)) 33 } 34 35 // AndSelf() adds the previous set of elements on the stack to the current set. 36 // It returns a new Selection object containing the current Selection combined 37 // with the previous one. 38 func (this *Selection) AndSelf() *Selection { 39 return this.AddSelection(this.prevSel) 40 }