refactor: Update parsing logic for JIT components
This commit is contained in:
parent
78d8d9fbc2
commit
d188f967d0
2 changed files with 5 additions and 4 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue