// appendElement appends the element to the htmlDocument or parent tagElement.
979297
func appendElement(htmlDoc *htmlDocument, parent *tagElement, e element) {
	if parent != nil {
		parent.appendChild(e)
	} else {
		htmlDoc.append(e)
	}
}
1139443
func (e *tagElement) write(bf *bytes.Buffer, indent int) {
	if Condense {
		l := len(e.children)
		if l == 0 {
			writeLine(bf, indent, e.startTagRaw, e.endTagRaw)
			return
		} else if l == 1 && e.endTagRaw != "" {
			if c, ok := e.children[0].(*textElement); ok {
				writeLine(bf, indent, e.startTagRaw, c.text, e.endTagRaw)
				return
			}
		}
	}

	writeLine(bf, indent, e.startTagRaw)
	for _, c := range e.children {
		var childIndent int
		if e.endTagRaw != "" {
			childIndent = indent + 1
		} else {
			childIndent = indent
		}
		c.write(bf, childIndent)
	}
	if e.endTagRaw != "" {
		writeLine(bf, indent, e.endTagRaw)
	}
}
1057361
func (d *Dataset) Append(row []interface{}) error {
	if len(row) != d.cols {
		return ErrInvalidDimensions
	}
	d.data = append(d.data, row)
	d.tags = append(d.tags, make([]string, 0))
	d.rows++
	return nil
}
496401
func (f *Form) RemoveElement(name string) *Form {
	ind, ok := f.fieldMap[name]
	if !ok {
		return f
	}
	delete(f.fieldMap, name)
	f.fields = append(f.fields[:ind], f.fields[ind+1:]...)
	return f
}
1291649
func writeElements(w io.Writer, elements ...interface{}) error {
	for _, element := range elements {
		err := writeElement(w, element)
		if err != nil {
			return err
		}
	}
	return nil
}
158793
func (p *parser) addElement() {
	p.addChild(&Node{
		Type:     ElementNode,
		DataAtom: p.tok.DataAtom,
		Data:     p.tok.Data,
		Attr:     p.tok.Attr,
	})
}
1008295
func SpecialAppendChild(o *js.Object, osets ...*js.Object) {
	for _, onode := range osets {
		// log.Printf("adding %+s -> %+s", o, onode)
		if strings.ToLower(onode.Get("tagName").String()) == "text" {
			SpecialAppendChild(o, ChildNodeList(onode)...)
			continue
		}
		o.Call("appendChild", onode)
	}
}
1282055
func newElement(ln *line, parent element) (element, error) {
	var e element
	var err error

	switch {
	case ln.isComment():
		e = newComment(ln, parent)
	case ln.isAtRule():
		e = newAtRule(ln, parent)
	case ln.isMixinDeclaration():
		// error can be ignored becuase the line is checked beforehand
		// by calling `ln.isMixinDeclaration()`.
		e, _ = newMixinDeclaration(ln, parent)
	case ln.isMixinInvocation():
		// error can be ignored becuase the line is checked beforehand
		// by calling `ln.isMixinInvocation()`.
		e, _ = newMixinInvocation(ln, parent)
	case ln.isVariable():
		e, err = newVariable(ln, parent)
	case ln.isDeclaration():
		e, err = newDeclaration(ln, parent)
	default:
		e, err = newSelector(ln, parent)
	}

	return e, err
}
147232
func (s *Selection) AppendSelection(sel *Selection) *Selection {
	return s.AppendNodes(sel.Nodes...)
}
750008
func (n *XMLNode) AddChild(child *XMLNode) {
	child.parent = n
	if _, ok := n.Children[child.Name.Local]; !ok {
		n.Children[child.Name.Local] = []*XMLNode{}
	}
	n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child)
}
1335392
func (t *TokenIntrospectionHandlers) Append(h TokenIntrospector) {
	for _, this := range *t {
		if reflect.TypeOf(this) == reflect.TypeOf(h) {
			return
		}
	}

	*t = append(*t, h)
}
975303
func (h *HTML) appendChild(child *HTML) {
	h.node.Call("appendChild", child.node)
}
429702
func (errs *MultiError) Append(err error) {
	if err != nil {
		*errs = append(*errs, err)
	}
}
1020043
func NewXMLElementFromHTMLNode(resp *Response, s *html.Node) *XMLElement {
	return &XMLElement{
		Name:       s.Data,
		Request:    resp.Request,
		Response:   resp,
		Text:       htmlquery.InnerText(s),
		DOM:        s,
		attributes: s.Attr,
		isHTML:     true,
	}
}
533446
func (sint *SliceInt) Append(num int) {
	sint.Elements = append(sint.Elements, num)
}
1047726
func (e *Element) populateElement(node *gcdapi.DOMNode) {
	e.lock.Lock()
	e.node = node
	e.id = node.NodeId
	e.nodeType = node.NodeType
	e.nodeName = strings.ToLower(node.NodeName)
	e.childNodeCount = node.ChildNodeCount
	if node.NodeType == int(TEXT_NODE) {
		e.characterData = node.NodeValue
	}

	e.lock.Unlock()

	for i := 0; i < len(node.Attributes); i += 2 {
		e.updateAttribute(node.Attributes[i], node.Attributes[i+1])
	}

	// close it
	if !e.ready {
		close(e.readyGate)
	}
	e.lock.Lock()
	defer e.lock.Unlock()
	e.ready = true
}
889725
func (eBase *elementBase) AppendChild(child element) {
	switch c := child.(type) {
	case *mixinInvocation:
		eBase.mixins = append(eBase.mixins, c)
	case *declaration:
		eBase.decs = append(eBase.decs, c)
	case *selector:
		eBase.sels = append(eBase.sels, c)
	}
}