From 9bae50b500fbc5d4692fa3180a0dffd1cce07ea9 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 9 Jul 2024 05:12:52 +0800 Subject: [PATCH] fix the bug in handling the replaceNodeUse attribute --- sui/core/data.go | 4 ++-- sui/core/parser.go | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sui/core/data.go b/sui/core/data.go index f08997e11..6df33f67c 100644 --- a/sui/core/data.go +++ b/sui/core/data.go @@ -135,8 +135,8 @@ func (data Data) replaceNodeUse(re *regexp.Regexp, node *html.Node) bool { case html.ElementNode: for i := range node.Attr { - // Keepwords - if strings.HasPrefix(node.Attr[i].Key, "s:") || node.Attr[i].Key == "is" { + + if (strings.HasPrefix(node.Attr[i].Key, "s:") || node.Attr[i].Key == "is") && !allowUsePropAttrs[node.Attr[i].Key] { continue } diff --git a/sui/core/parser.go b/sui/core/parser.go index 795d31799..037403977 100644 --- a/sui/core/parser.go +++ b/sui/core/parser.go @@ -65,6 +65,13 @@ var keepWords = map[string]bool{ "s:bind": true, } +var allowUsePropAttrs = map[string]bool{ + "s:if": true, + "s:elif": true, + "s:for": true, + "s:click": true, +} + var keepAttrs = map[string]bool{ "s:ns": true, "s:cn": true,