Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
its-the-shrimp committed Sep 27, 2023
1 parent dd2338d commit 9879233
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
4 changes: 3 additions & 1 deletion packages/yew-macro/src/html_tree/html_dashed_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ impl fmt::Display for HtmlDashedName {
impl Peek<'_, Self> for HtmlDashedName {
fn peek(cursor: Cursor) -> Option<(Self, Cursor)> {
let (name, cursor) = cursor.ident()?;
if !non_capitalized_ascii(&name.to_string()) {return None}
if !non_capitalized_ascii(&name.to_string()) {
return None;
}

let mut extended = Vec::new();
let mut cursor = cursor;
Expand Down
24 changes: 17 additions & 7 deletions packages/yew-macro/src/html_tree/html_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,9 @@ pub struct DynamicName {
impl Peek<'_, ()> for DynamicName {
fn peek(cursor: Cursor) -> Option<((), Cursor)> {
let (punct, cursor) = cursor.punct()?;
if punct.as_char() != '@' {return None}
if punct.as_char() != '@' {
return None;
}

// move cursor past block if there is one
let cursor = cursor
Expand Down Expand Up @@ -606,17 +608,21 @@ impl HtmlElementOpen {
impl PeekValue<TagKey> for HtmlElementOpen {
fn peek(cursor: Cursor) -> Option<TagKey> {
let (punct, cursor) = cursor.punct()?;
if punct.as_char() != '<' {return None}
if punct.as_char() != '<' {
return None;
}

let (tag_key, cursor) = TagName::peek(cursor)?;
if let TagKey::Lit(name) = &tag_key {
// Avoid parsing `<key=[...]>` as an element. It needs to be parsed as an `HtmlList`.
if name.to_string() == "key" {
let (punct, _) = cursor.punct()?;
// ... unless it isn't followed by a '='. `<key></key>` is a valid element!
if punct.as_char() == '=' {return None}
if punct.as_char() == '=' {
return None;
}
} else if !non_capitalized_ascii(&name.to_string()) {
return None
return None;
}
}

Expand Down Expand Up @@ -674,14 +680,18 @@ impl HtmlElementClose {
impl PeekValue<TagKey> for HtmlElementClose {
fn peek(cursor: Cursor) -> Option<TagKey> {
let (punct, cursor) = cursor.punct()?;
if punct.as_char() != '<' {return None}
if punct.as_char() != '<' {
return None;
}

let (punct, cursor) = cursor.punct()?;
if punct.as_char() != '/' {return None}
if punct.as_char() != '/' {
return None;
}

let (tag_key, cursor) = TagName::peek(cursor)?;
if matches!(&tag_key, TagKey::Lit(name) if !non_capitalized_ascii(&name.to_string())) {
return None
return None;
}

let (punct, _) = cursor.punct()?;
Expand Down
12 changes: 9 additions & 3 deletions packages/yew-macro/src/html_tree/html_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ impl HtmlListOpen {
impl PeekValue<()> for HtmlListOpen {
fn peek(cursor: Cursor) -> Option<()> {
let (punct, cursor) = cursor.punct()?;
if punct.as_char() != '<' {return None}
if punct.as_char() != '<' {
return None;
}
// make sure it's either a property (key=value) or it's immediately closed
if let Some((_, cursor)) = HtmlDashedName::peek(cursor) {
let (punct, _) = cursor.punct()?;
Expand Down Expand Up @@ -155,9 +157,13 @@ impl HtmlListClose {
impl PeekValue<()> for HtmlListClose {
fn peek(cursor: Cursor) -> Option<()> {
let (punct, cursor) = cursor.punct()?;
if punct.as_char() != '<' {return None}
if punct.as_char() != '<' {
return None;
}
let (punct, cursor) = cursor.punct()?;
if punct.as_char() != '/' {return None}
if punct.as_char() != '/' {
return None;
}

let (punct, _) = cursor.punct()?;
(punct.as_char() == '>').then_some(())
Expand Down

0 comments on commit 9879233

Please sign in to comment.