From 40ecbde86b46376312d2306b6cf6013ab305f884 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 27 Jul 2024 08:06:04 +0800 Subject: [PATCH] Optimize SUI core to copy json-attr- to the prop in newJitComponentSel function --- sui/core/jit.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sui/core/jit.go b/sui/core/jit.go index 185b4d5d..1dc3aba5 100644 --- a/sui/core/jit.go +++ b/sui/core/jit.go @@ -88,7 +88,6 @@ func (parser *TemplateParser) newJitComponentSel(sel *goquery.Selection, comp *J for key, val := range props { var v interface{} = val if props[fmt.Sprintf("json-attr-%s", key)] == "true" { - fmt.Println("json-attr-", key) err := jsoniter.UnmarshalFromString(val, &v) if err != nil { v = fmt.Sprintf(`"%s"`, val) @@ -104,10 +103,15 @@ func (parser *TemplateParser) newJitComponentSel(sel *goquery.Selection, comp *J compSel := doc.Find("body").Children().First() data.replaceNodeUse(propTokens, compSel.Nodes[0]) for key, val := range props { - if strings.HasPrefix(key, "s:") || strings.HasPrefix(key, "json-attr-") || key == "parsed" { + if strings.HasPrefix(key, "s:") || key == "parsed" { compSel.SetAttr(key, val) continue } + // copy the json-attr- to the prop: + if strings.HasPrefix(key, "json-attr-") { + compSel.SetAttr(fmt.Sprintf("json-attr-prop:%s", key[10:]), val) + continue + } compSel.SetAttr(fmt.Sprintf("prop:%s", key), val) }