Skip to content
Snippets Groups Projects
Verified Commit 389f756d authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: remove changend attributes

parent f1d15573
No related branches found
No related tags found
No related merge requests found
...@@ -161,6 +161,9 @@ func doModifications(page *types.PageData, from string) (string, error) { ...@@ -161,6 +161,9 @@ func doModifications(page *types.PageData, from string) (string, error) {
list := cascadia.QueryAll(node, selector) list := cascadia.QueryAll(node, selector)
for _, n := range list { for _, n := range list {
if n.Parent != nil { if n.Parent != nil {
removeAttr(n, m.Name)
attr := n.Attr attr := n.Attr
attr = append(attr, html.Attribute{ attr = append(attr, html.Attribute{
Key: m.Name, Key: m.Name,
...@@ -180,3 +183,17 @@ func doModifications(page *types.PageData, from string) (string, error) { ...@@ -180,3 +183,17 @@ func doModifications(page *types.PageData, from string) (string, error) {
return stringWriter.String(), nil return stringWriter.String(), nil
} }
func removeAttr(n *html.Node, search string) {
i := -1
for index, attr := range n.Attr {
if attr.Key == search {
i = index
break
}
}
if i != -1 {
n.Attr = append(n.Attr[:i], n.Attr[i+1:]...)
}
}
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<script id="translations" type="application/json" data-monster-role="translation">{"key1":"value1","key2":"value2","key3":{"one":"value3","two":"value4"}}</script> <script id="translations" type="application/json" data-monster-role="translation">{"key1":"value1","key2":"value2","key3":{"one":"value3","two":"value4"}}</script>
<script id="mainscript" src="/script/main22.mjs" type="module" data-xyz="YES"></script> <script id="mainscript" src="/script/main22.mjs" type="module" type="YES"></script>
</head> </head>
<body> <body>
......
...@@ -60,7 +60,7 @@ test1.html: ...@@ -60,7 +60,7 @@ test1.html:
html: <b><span>GURKE</span></b> html: <b><span>GURKE</span></b>
attributes: attributes:
- selector: '#mainscript' - selector: '#mainscript'
name: data-xyz name: type
value: YES value: YES
test2.html: test2.html:
export: en/test2.html export: en/test2.html
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment