From 265188bed12fc594be6749e5257582d3b5cae3aa Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 7 Jul 2024 16:00:28 +0800 Subject: [PATCH] refactor: Remove unused slotNode function and tidy up code --- sui/core/parser.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sui/core/parser.go b/sui/core/parser.go index 3ab235bfc..d2e107801 100644 --- a/sui/core/parser.go +++ b/sui/core/parser.go @@ -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 }