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

fix: remove attributes that are set

parent 9432983a
No related branches found
No related tags found
No related merge requests found
......@@ -200,7 +200,7 @@ func (e *Engine) processRepeat(node *html.Node, attr html.Attribute) *Engine {
errors = runNode(node, data, key, item, nextSibling, parent)
}
default:
e.errors = append(e.errors, &UnsupportedTypeError{Message: "Unsupported iterator type", NodeType: node.Type})
}
......@@ -626,6 +626,8 @@ func (e *Engine) processAttributes(node *html.Node, attr html.Attribute) *Engine
cVal = val.(string)
}
node.Attr = removeAttribute(node.Attr, key)
node.Attr = append(node.Attr, html.Attribute{
Key: key,
Val: cVal,
......
package engine
import (
"github.com/stretchr/testify/assert"
"golang.org/x/net/html"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"golang.org/x/net/html"
)
func TestNewEngine(t *testing.T) {
......@@ -56,6 +57,14 @@ func TestProcessHtml(t *testing.T) {
expected string
data map[any]any
}{
{
html: `<!DOCTYPE html><html lang="en" data-attributes="lang path:lang"><head><body>`,
hasErrors: false,
expected: `<!DOCTYPE html><html lang="en"><head></head><body></body></html>`,
data: map[any]any{
"lang": "en",
},
},
{
html: `<div data-test="test"></div>`,
hasErrors: false,
......
......@@ -3,13 +3,16 @@ module gitlab.schukai.com/oss/libraries/go/markup/html
go 1.19
require (
github.com/andybalholm/cascadia v1.3.1
github.com/stretchr/testify v1.8.1
gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.0
golang.org/x/net v0.2.0
)
require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/volker-schukai/tokenizer v1.0.0 // indirect
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
......@@ -8,10 +8,17 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/volker-schukai/tokenizer v1.0.0 h1:wF4haFoCodq7lgAk8c+th/DZmpFpL2WVD8wDzAGU1mA=
github.com/volker-schukai/tokenizer v1.0.0/go.mod h1:LPw7lLIxUnZgeg96818N7IvwLE1x8ya31J/Aa0aCq9M=
gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.0 h1:JVxMHiA8zFVjJDhNl65XeYrhdMkzB+5dyrBUEZ982WU=
gitlab.schukai.com/oss/libraries/go/utilities/data.git v0.2.0/go.mod h1:BsR4Y9jsvISplkW6UoLFRGxQX69/AUmP1SXRwWhx31o=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.4.0 h1:eAEsq3lsHwMe5Zz71vNab5csPtp8S+i5zFPmNnDPFDg=
gitlab.schukai.com/oss/libraries/go/utilities/pathfinder v0.4.0/go.mod h1:UvdD4NAf3gLKYafabJD7e9ZCOetzM9JZ9y4GkZukPVU=
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
......
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