Refactor SUI core to improve import parsing and aliasing
This commit is contained in:
parent
1763a4f2e7
commit
4c5278938c
1 changed files with 4 additions and 5 deletions
|
|
@ -248,15 +248,15 @@ func (page *Page) BuildAsComponent(sel *goquery.Selection, ctx *BuildContext, op
|
||||||
}
|
}
|
||||||
|
|
||||||
func (page *Page) parseImports(doc *goquery.Document) {
|
func (page *Page) parseImports(doc *goquery.Document) {
|
||||||
imports := doc.Find("s\\:import")
|
imports := doc.Find("import")
|
||||||
mapping := map[string]PageImport{}
|
mapping := map[string]PageImport{}
|
||||||
for i := 0; i < imports.Length(); i++ {
|
for i := 0; i < imports.Length(); i++ {
|
||||||
defer imports.Eq(i).Remove()
|
name := imports.Eq(i).AttrOr("s:as", "")
|
||||||
name := imports.Eq(i).AttrOr("s:name", "")
|
|
||||||
from := imports.Eq(i).AttrOr("s:from", "")
|
from := imports.Eq(i).AttrOr("s:from", "")
|
||||||
if name == "" || from == "" {
|
if name == "" || from == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
defer imports.Eq(i).Remove()
|
||||||
if _, has := mapping[name]; has {
|
if _, has := mapping[name]; has {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
@ -295,10 +295,9 @@ func (page *Page) parseImports(doc *goquery.Document) {
|
||||||
// Copy the attributes
|
// Copy the attributes
|
||||||
selection.SetAttr("is", imp.is)
|
selection.SetAttr("is", imp.is)
|
||||||
for _, attr := range imp.selection.Get(0).Attr {
|
for _, attr := range imp.selection.Get(0).Attr {
|
||||||
if strings.HasPrefix(attr.Key, "s:") {
|
if attr.Key == "s:as" || attr.Key == "s:from" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, has := selection.Attr(attr.Key); !has {
|
if _, has := selection.Attr(attr.Key); !has {
|
||||||
selection.SetAttr(attr.Key, attr.Val)
|
selection.SetAttr(attr.Key, attr.Val)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue