fix the bug in handling the replaceNodeUse attribute

This commit is contained in:
Max 2024-07-09 05:12:52 +08:00
parent 31cf9061e8
commit 9bae50b500
2 changed files with 9 additions and 2 deletions

View file

@ -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
}

View file

@ -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,