create header and footer only when needed
parent
406008135f
commit
4b4b875f34
|
@ -93,28 +93,30 @@ func merge(base, doc *html.Node) (out *html.Node) {
|
|||
footer := findRec(body, atom.Footer)
|
||||
main := findRec(body, atom.Main)
|
||||
|
||||
if header == nil {
|
||||
header = createElement(atom.Header)
|
||||
body.InsertBefore(header, body.FirstChild)
|
||||
}
|
||||
// TODO: merge attributes
|
||||
|
||||
for {
|
||||
n := findRec(newBody, atom.Header)
|
||||
if n == nil {
|
||||
break
|
||||
}
|
||||
if header == nil {
|
||||
header = createElement(atom.Header)
|
||||
body.InsertBefore(header, body.FirstChild)
|
||||
}
|
||||
reparentChildren(header, n)
|
||||
n.Parent.RemoveChild(n)
|
||||
}
|
||||
|
||||
if footer == nil {
|
||||
footer = createElement(atom.Header)
|
||||
body.InsertBefore(footer, body.FirstChild)
|
||||
}
|
||||
for {
|
||||
n := findRec(newBody, atom.Footer)
|
||||
if n == nil {
|
||||
break
|
||||
}
|
||||
if footer == nil {
|
||||
footer = createElement(atom.Header)
|
||||
body.InsertBefore(footer, body.FirstChild)
|
||||
}
|
||||
reparentChildren(footer, n)
|
||||
n.Parent.RemoveChild(n)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue