Skip to content

Commit

Permalink
increase maximum size of attribute name from 15 characters to 128 - f…
Browse files Browse the repository at this point in the history
…ixes #15
  • Loading branch information
a-h committed Jun 7, 2021
1 parent 7f62d8c commit 9545078
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion elementparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var attributeNameFirst = "abcdefghijklmnopqrstuvwxyz"
var attributeNameSubsequent = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-"
var attributeNameParser = parse.Then(parse.WithStringConcatCombiner,
parse.RuneIn(elementNameFirst),
parse.Many(parse.WithStringConcatCombiner, 0, 15, parse.RuneIn(elementNameSubsequent)),
parse.Many(parse.WithStringConcatCombiner, 0, 128, parse.RuneIn(elementNameSubsequent)),
)

// Constant attribute.
Expand Down
18 changes: 18 additions & 0 deletions elementparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ func TestAttributeParser(t *testing.T) {
Value: "test",
},
},
{
name: "attribute name with hyphens",
input: ` data-turbo-permanent="value"`,
parser: newConstantAttributeParser().Parse,
expected: ConstantAttribute{
Name: "data-turbo-permanent",
Value: "value",
},
},
{
name: "empty attribute",
input: ` data=""`,
parser: newConstantAttributeParser().Parse,
expected: ConstantAttribute{
Name: "data",
Value: "",
},
},
{
name: "attribute containing escaped text",
input: ` href="<">"`,
Expand Down

0 comments on commit 9545078

Please sign in to comment.