Merge pull request #668 from trheyi/main
refactor: Update parsing logic for JIT components
This commit is contained in:
commit
012c781046
2 changed files with 5 additions and 4 deletions
|
|
@ -39,6 +39,7 @@ func init() {
|
||||||
|
|
||||||
// parseComponent parse the component
|
// parseComponent parse the component
|
||||||
func (parser *TemplateParser) parseComponent(sel *goquery.Selection) {
|
func (parser *TemplateParser) parseComponent(sel *goquery.Selection) {
|
||||||
|
parser.parsed(sel)
|
||||||
comp, props, slots, err := parser.getComponent(sel)
|
comp, props, slots, err := parser.getComponent(sel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
parser.errors = append(parser.errors, err)
|
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
|
// Remove the tag and replace it with the children
|
||||||
func (parser *TemplateParser) removeSlotWrapper(sel *goquery.Selection) {
|
func (parser *TemplateParser) removeWrapper(sel *goquery.Selection) {
|
||||||
children := sel.Children()
|
children := sel.Children()
|
||||||
if children.Length() == 0 {
|
if children.Length() == 0 {
|
||||||
sel.Remove()
|
sel.Remove()
|
||||||
|
|
@ -648,9 +648,9 @@ func (parser *TemplateParser) tidy(s *goquery.Selection) {
|
||||||
s.Contents().Each(func(i int, child *goquery.Selection) {
|
s.Contents().Each(func(i int, child *goquery.Selection) {
|
||||||
|
|
||||||
node := child.Get(0)
|
node := child.Get(0)
|
||||||
if node.Data == "slot" {
|
if _, exist := child.Attr("s:jit"); node.Data == "slot" || exist {
|
||||||
parser.tidy(child)
|
parser.tidy(child)
|
||||||
parser.removeSlotWrapper(child)
|
parser.removeWrapper(child)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue