From d188f967d0af0ed9f435cff0d4b92db3ced24fc3 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 8 Jul 2024 02:21:36 +0800 Subject: [PATCH] refactor: Update parsing logic for JIT components --- sui/core/jit.go | 1 + sui/core/parser.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sui/core/jit.go b/sui/core/jit.go index 6ad82d5f..8daa74e2 100644 --- a/sui/core/jit.go +++ b/sui/core/jit.go @@ -39,6 +39,7 @@ func init() { // parseComponent parse the component func (parser *TemplateParser) parseComponent(sel *goquery.Selection) { + parser.parsed(sel) comp, props, slots, err := parser.getComponent(sel) if err != nil { parser.errors = append(parser.errors, err) diff --git a/sui/core/parser.go b/sui/core/parser.go index e9789bb4..57ad5706 100644 --- a/sui/core/parser.go +++ b/sui/core/parser.go @@ -316,8 +316,8 @@ func (parser *TemplateParser) transElementNode(sel *goquery.Selection) { } } -// Remove the slot tag and replace it with the children -func (parser *TemplateParser) removeSlotWrapper(sel *goquery.Selection) { +// Remove the tag and replace it with the children +func (parser *TemplateParser) removeWrapper(sel *goquery.Selection) { children := sel.Children() if children.Length() == 0 { sel.Remove() @@ -648,9 +648,9 @@ func (parser *TemplateParser) tidy(s *goquery.Selection) { s.Contents().Each(func(i int, child *goquery.Selection) { node := child.Get(0) - if node.Data == "slot" { + if _, exist := child.Attr("s:jit"); node.Data == "slot" || exist { parser.tidy(child) - parser.removeSlotWrapper(child) + parser.removeWrapper(child) return }