Skip to content

Commit

Permalink
feat: make component tag prefix case pass and require case set up
Browse files Browse the repository at this point in the history
  • Loading branch information
meloalright committed Feb 20, 2024
1 parent 9fe2000 commit fff5443
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions rustle/src/compiler/parse/fragments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use swc_ecma_ast::{Expr, Script};
use swc_html_ast::Text;

lazy_static! {
static ref COMPONENT_TAG_PREFIX: Regex = Regex::new("[A-Z]").unwrap();
static ref ELEMENT_TAG_NAME: Regex = Regex::new("[a-z]").unwrap();
static ref ATTRIBUTE_NAME: Regex = Regex::new("[^=]").unwrap();
static ref READ_TEXT: Regex = Regex::new("[^<{]").unwrap();
Expand Down Expand Up @@ -105,7 +106,9 @@ fn parse_element(parser: &mut Parser) -> Option<RustleElement> {
return None;
}

let prefix = parser.read_while_matching(&COMPONENT_TAG_PREFIX);
let tag_name = parser.read_while_matching(&ELEMENT_TAG_NAME);
let tag_name = format!("{}{}", prefix, tag_name);
let attributes = parse_attribute_list(parser);

if parser.match_str("/>") {
Expand Down
5 changes: 2 additions & 3 deletions rustle/tests/nested/app.rustle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script>
import Nested from './Nested.rustle';
const Nested = require('./Nested.rustle');
</script>

<p>These styles...</p>
<Nested />
<Nested />
4 changes: 2 additions & 2 deletions rustle/tests/test_parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ fn test_parsing_hello() { test_parsing("hello".to_owned()) }
#[test]
fn test_parsing_reactive_assignments() { test_parsing("reactive-assignments".to_owned()) }

// #[test]
// fn test_parsing_nested() { test_parsing("nested".to_owned()) }
#[test]
fn test_parsing_nested() { test_parsing("nested".to_owned()) }

0 comments on commit fff5443

Please sign in to comment.