-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handling attributes in JSX elements #2
Conversation
crates/core/src/shared/transform.rs
Outdated
allocator::{Allocator, Vec as OxcVec}, | ||
ast::ast::{self, JSXElementName}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these are not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed 0871357
crates/core/src/shared/transform.rs
Outdated
let mut child_tmpls = String::new(); | ||
let info = TransformInfo::default(); | ||
for child in children { | ||
match self.transform_node(child, ctx, &info) { | ||
Some(child_result) => { | ||
if let Some(child_tmpl) = child_result.template { | ||
child_tmpls.push_str(&child_tmpl); | ||
} | ||
} | ||
None => {} | ||
} | ||
} | ||
child_tmpls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be more performant to use .filter_map()
and .collect::<String>()
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was also a clean approach. modified here. 0871357
crates/core/src/shared/transform.rs
Outdated
use super::*; | ||
use oxc::{allocator::Allocator, parser::Parser, semantic::SemanticBuilder, span::SourceType}; | ||
|
||
struct test_case { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clippy wouldn't like the casing 😅 (I'll set it up in the CI soon)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clippy would love this fix 3c91e3b
Co-authored-by: Iha Shin (신의하) <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a great starting point!
Description
Handling of
class
Attribute in JSX Elements:transform_element
function now extracts theclass
attribute from JSX elements and includes it in the generated HTML string.Handling Element without
class
Attribute:class
attribute is not exists, the function generates an HTML string that includes only the element tag and its content. (e.g.,<div>Hello
)The expected value of the test used the client-side rendering result of SolidJS.