-
Notifications
You must be signed in to change notification settings - Fork 12
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
98 data phx ref support #255
base: main
Are you sure you want to change the base?
98 data phx ref support #255
Conversation
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.
This is pretty good. I know there's some merge conflicts due to #256. The changes are deep into the patch diffing that I've avoided.
I think the attr, element, const_attr macros make the tests a lot nicer. I'd just suggest that they be in the test modules.
#[macro_export] | ||
macro_rules! attr { | ||
($name:literal) => { | ||
Attribute::new($name, None) | ||
}; | ||
($name:literal= $value:expr) => { | ||
Attribute::new($name, Some($value.to_string())) | ||
}; | ||
($namespace:literal : $name:literal) => { | ||
Attribute { | ||
name: AttributeName::new_with_namespace($namespace, $name), | ||
value: None, | ||
} | ||
}; | ||
($namespace:literal : $name:literal = $value:expr) => { | ||
Attribute { | ||
name: AttributeName::new_with_namespace($namespace, $name), | ||
value: Some($value.to_string()), | ||
} | ||
}; | ||
} | ||
|
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.
At this moment, I think this macro is only used in tests so it should probably go behind a #[cfg(test)]
or in a test module.
@@ -309,3 +333,34 @@ impl Element { | |||
} | |||
} | |||
} | |||
|
|||
#[macro_export] | |||
macro_rules! element { |
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.
Same thing about this only being used in tests.
element!( | ||
"Button", | ||
attr!("id" = "button"), | ||
attr!("phx-click" = "inc_temperature"), | ||
attr!("data-phx-ref-src" = "5"), | ||
attr!("class" = "phx-click-loading") | ||
) |
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.
This is pretty clean.
No description provided.