refactor: Remove unused slotNode function and tidy up code

This commit is contained in:
Max 2024-07-07 16:00:28 +08:00
parent e4c8eeb180
commit 265188bed1

View file

@ -295,11 +295,6 @@ func (parser *TemplateParser) parseElementNode(sel *goquery.Selection) {
parser.parseJitElementNode(sel)
}
// Slot Node
if node.Data == "slot" {
parser.slotNode(sel)
}
// Parse the attributes
parser.parseElementAttrs(sel)
@ -374,7 +369,7 @@ func (parser *TemplateParser) transElementNode(sel *goquery.Selection) {
}
// Remove the slot tag and replace it with the children
func (parser *TemplateParser) slotNode(sel *goquery.Selection) {
func (parser *TemplateParser) removeSlotWrapper(sel *goquery.Selection) {
children := sel.Children()
if children.Length() == 0 {
sel.Remove()
@ -705,8 +700,14 @@ func (parser *TemplateParser) tidy(s *goquery.Selection) {
s.Contents().Each(func(i int, child *goquery.Selection) {
node := child.Get(0)
if node.Data == "slot" {
parser.tidy(child)
parser.removeSlotWrapper(child)
return
}
if node.Type == html.CommentNode {
child = child.Remove()
child.Remove()
return
}