From 0076ae6627737af5970c68c708b1124ca939dcc4 Mon Sep 17 00:00:00 2001
From: JesseBrault0709 <62299747+JesseBrault0709@users.noreply.github.com>
Date: Thu, 13 Jun 2024 20:01:30 +0200
Subject: [PATCH] Fixed hyphenated attributes.
---
TODO.md | 1 +
.../src/main/antlr/WebViewComponentsLexerBase.g4 | 2 +-
web-view-components-compiler/src/test/lexer/hyphenAttr.wvc | 1 +
web-view-components-compiler/src/test/lexer/hyphenType.wvc | 1 +
.../src/test/lexer/tokens-files/hyphenAttr_tokens.txt | 7 +++++++
.../src/test/lexer/tokens-files/hyphenType_tokens.txt | 5 +++++
web-view-components-compiler/src/tools/binTemplate.gst | 4 ++--
7 files changed, 18 insertions(+), 3 deletions(-)
create mode 100644 web-view-components-compiler/src/test/lexer/hyphenAttr.wvc
create mode 100644 web-view-components-compiler/src/test/lexer/hyphenType.wvc
create mode 100644 web-view-components-compiler/src/test/lexer/tokens-files/hyphenAttr_tokens.txt
create mode 100644 web-view-components-compiler/src/test/lexer/tokens-files/hyphenType_tokens.txt
diff --git a/TODO.md b/TODO.md
index d94d67c..26c412a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -28,6 +28,7 @@ For example:
```
```
+- [x] `data-` attributes need to function correctly (really any attribute with hyphen).
## 0.1.1
- [x] `Switch` and `Case` components
diff --git a/web-view-components-compiler/src/main/antlr/WebViewComponentsLexerBase.g4 b/web-view-components-compiler/src/main/antlr/WebViewComponentsLexerBase.g4
index 115cdaf..ba5ca9d 100644
--- a/web-view-components-compiler/src/main/antlr/WebViewComponentsLexerBase.g4
+++ b/web-view-components-compiler/src/main/antlr/WebViewComponentsLexerBase.g4
@@ -307,7 +307,7 @@ AttributeIdentifierStartChar
fragment
AttributeIdentifierChar
- : [\p{L}_$0-9]
+ : [-\p{L}_$0-9]
;
Equals
diff --git a/web-view-components-compiler/src/test/lexer/hyphenAttr.wvc b/web-view-components-compiler/src/test/lexer/hyphenAttr.wvc
new file mode 100644
index 0000000..1133cdc
--- /dev/null
+++ b/web-view-components-compiler/src/test/lexer/hyphenAttr.wvc
@@ -0,0 +1 @@
+
diff --git a/web-view-components-compiler/src/test/lexer/hyphenType.wvc b/web-view-components-compiler/src/test/lexer/hyphenType.wvc
new file mode 100644
index 0000000..5e2dadd
--- /dev/null
+++ b/web-view-components-compiler/src/test/lexer/hyphenType.wvc
@@ -0,0 +1 @@
+
diff --git a/web-view-components-compiler/src/test/lexer/tokens-files/hyphenAttr_tokens.txt b/web-view-components-compiler/src/test/lexer/tokens-files/hyphenAttr_tokens.txt
new file mode 100644
index 0000000..1a39880
--- /dev/null
+++ b/web-view-components-compiler/src/test/lexer/tokens-files/hyphenAttr_tokens.txt
@@ -0,0 +1,7 @@
+0: ComponentOpen[1,1](<)
+1: StringIdentifier[1,2](test)
+2: Nlws[1,6]( )
+3: AttributeIdentifier[1,7](test-attr)
+4: Nlws[1,16]( )
+5: ComponentSelfClose[1,17](/>)
+6: RawText[1,19](\n)
\ No newline at end of file
diff --git a/web-view-components-compiler/src/test/lexer/tokens-files/hyphenType_tokens.txt b/web-view-components-compiler/src/test/lexer/tokens-files/hyphenType_tokens.txt
new file mode 100644
index 0000000..72f31b8
--- /dev/null
+++ b/web-view-components-compiler/src/test/lexer/tokens-files/hyphenType_tokens.txt
@@ -0,0 +1,5 @@
+0: ComponentOpen[1,1](<)
+1: StringIdentifier[1,2](test-type)
+2: Nlws[1,11]( )
+3: ComponentSelfClose[1,12](/>)
+4: RawText[1,14](\n)
\ No newline at end of file
diff --git a/web-view-components-compiler/src/tools/binTemplate.gst b/web-view-components-compiler/src/tools/binTemplate.gst
index 60e9deb..82e6abc 100644
--- a/web-view-components-compiler/src/tools/binTemplate.gst
+++ b/web-view-components-compiler/src/tools/binTemplate.gst
@@ -2,7 +2,7 @@
if [ "\$1" == "--debug" ]; then
shift
- gradle -q toolsJar && java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8192 -cp build/libs/web-view-components-compiler-tools-0.1.0.jar $mainClassName "\$@"
+ gradle -q toolsJar && java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8192 -cp build/libs/web-view-components-compiler-tools-0.1.1.jar $mainClassName "\$@"
else
- gradle -q toolsJar && java -cp build/libs/web-view-components-compiler-tools-0.1.0.jar $mainClassName "\$@"
+ gradle -q toolsJar && java -cp build/libs/web-view-components-compiler-tools-0.1.1.jar $mainClassName "\$@"
fi