MCPcopy
hub / github.com/golang/net / addText

Method addText

html/parse.go:304–326  ·  view source on GitHub ↗

addText adds text to the preceding node if it is a text node, or else it calls addChild with a new text node.

(text string)

Source from the content-addressed store, hash-verified

302// addText adds text to the preceding node if it is a text node, or else it
303// calls addChild with a new text node.
304func (p *parser) addText(text string) {
305 if text == "" {
306 return
307 }
308
309 if p.shouldFosterParent() {
310 p.fosterParent(&Node{
311 Type: TextNode,
312 Data: text,
313 })
314 return
315 }
316
317 t := p.top()
318 if n := t.LastChild; n != nil && n.Type == TextNode {
319 n.Data += text
320 return
321 }
322 p.addChild(&Node{
323 Type: TextNode,
324 Data: text,
325 })
326}
327
328func attrCompare(a, b Attribute) int {
329 return cmp.Or(

Callers 9

inHeadIMFunction · 0.80
afterHeadIMFunction · 0.80
inBodyIMFunction · 0.80
textIMFunction · 0.80
inTableIMFunction · 0.80
inColumnGroupIMFunction · 0.80
inFramesetIMFunction · 0.80
afterFramesetIMFunction · 0.80
parseForeignContentFunction · 0.80

Calls 4

shouldFosterParentMethod · 0.95
fosterParentMethod · 0.95
topMethod · 0.95
addChildMethod · 0.95

Tested by

no test coverage detected