Skip to content

Commit

Permalink
refactor: Remove unused slotNode function and tidy up code
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Jul 7, 2024
1 parent e4c8eeb commit 265188b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions sui/core/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 265188b

Please sign in to comment.