MCPcopy
hub / github.com/tdewolff/minify / read

Method read

html/buffer.go:40–63  ·  view source on GitHub ↗
(t *Token)

Source from the content-addressed store, hash-verified

38}
39
40func (z *TokenBuffer) read(t *Token) {
41 t.Offset = z.r.Offset()
42 t.TokenType, t.Data = z.l.Next()
43 t.Text = z.l.Text()
44 t.HasTemplate = z.l.HasTemplate()
45 if t.TokenType == html.AttributeToken {
46 t.Offset += 1 + len(t.Text) + 1
47 t.AttrVal = z.l.AttrVal()
48 if 1 < len(t.AttrVal) && (t.AttrVal[0] == '"' || t.AttrVal[0] == '\'') {
49 t.Offset++
50 t.AttrVal = t.AttrVal[1 : len(t.AttrVal)-1] // quotes will be readded in attribute loop if necessary
51 }
52 t.Hash = ToHash(t.Text)
53 t.Traits = attrMap[t.Hash]
54 } else if t.TokenType == html.StartTagToken || t.TokenType == html.EndTagToken {
55 t.AttrVal = nil
56 t.Hash = ToHash(t.Text)
57 t.Traits = tagMap[t.Hash] // zero if not exist
58 } else {
59 t.AttrVal = nil
60 t.Hash = 0
61 t.Traits = 0
62 }
63}
64
65// Peek returns the ith element and possibly does an allocation.
66// Peeking past an error will panic.

Callers 2

PeekMethod · 0.95
ShiftMethod · 0.95

Calls 2

lenFunction · 0.85
ToHashFunction · 0.70

Tested by

no test coverage detected