Merge pull request #10 from axodotdev/fix-data

Fix data attributes && add ability to have script in HTML
This commit is contained in:
ashley williams 2022-12-23 09:31:17 -06:00 committed by GitHub
commit f392e6daac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -76,7 +76,10 @@ fn extract_data_attrs(attrs: &mut StringyMap<Ident, TokenTree>) -> StringyMap<St
let key_name = key.to_string();
if let Some(key_name) = key_name.strip_prefix("data_") {
let value = attrs.remove(&key).unwrap();
data.insert(key_name.to_string(), value);
// makes sure if a data attribute has more than one hyphen
// they all get transformed
let key = str::replace(key_name, "_", "-");
data.insert(key.to_string(), value);
}
}
data

View File

@ -31,6 +31,7 @@ macro_rules! marker_trait {
};
}
marker_trait!(HTMLContent);
marker_trait!(MetadataContent);
marker_trait!(FlowContent);
marker_trait!(SectioningContent);
@ -53,7 +54,7 @@ marker_trait!(TableColumnContent);
declare_elements! {
html {
xmlns: Uri,
} with [head, body];
} with [head, body] HTMLContent;
head with [title] MetadataContent;
body with FlowContent;
@ -311,7 +312,7 @@ declare_elements! {
src: Uri,
text: String,
type: String, // TODO could be an enum
} in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent] with TextNode;
} in [MetadataContent, FlowContent, PhrasingContent, TableColumnContent, HTMLContent] with TextNode;
section in [FlowContent, SectioningContent] with FlowContent;
select {
autocomplete: String,