-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
60 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "html-macro" | ||
version = "0.1.2" | ||
version = "0.1.3" | ||
description = "html macro" | ||
authors = ["Chinedu Francis Nwafili <[email protected]>"] | ||
keywords = ["virtual", "dom", "wasm", "assembly", "webassembly"] | ||
|
@@ -16,5 +16,4 @@ proc-macro = true | |
proc-macro2 = { version = "0.4", features = ["span-locations"] } | ||
quote = "0.6.11" | ||
syn = { version = "0.15", features = ["full", "extra-traits"] } | ||
# TODO: Remove this in favor of crates/html-validation | ||
virtual-node = { path = "../virtual-node", version = "0.2.3" } | ||
html-validation = {path = "../html-validation", version = "0.1.0"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "html-validation" | ||
version = "0.1.0" | ||
authors = ["Chinedu Francis Nwafili <[email protected]>"] | ||
description = "Validation for HTML elements and attributes" | ||
keywords = ["html", "validation", "valid", "dom", "virtual"] | ||
license = "MIT/Apache-2.0" | ||
repository = "https://github.com/chinedufn/percy" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
lazy_static = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Validation for html attributes and elements | ||
#![deny(missing_docs)] | ||
|
||
use lazy_static::lazy_static; | ||
use std::collections::hash_set::HashSet; | ||
|
||
// Used to uniquely identify elements that contain closures so that the DomUpdater can | ||
// look them up by their unique id. | ||
// When the DomUpdater sees that the element no longer exists it will drop all of it's | ||
// Rc'd Closures for those events. | ||
lazy_static! { | ||
static ref SELF_CLOSING_TAGS: HashSet<&'static str> = [ | ||
"area", "base", "br", "col", "hr", "img", "input", "link", "meta", "param", "command", | ||
"keygen", "source", | ||
] | ||
.iter() | ||
.cloned() | ||
.collect(); | ||
} | ||
|
||
/// Whether or not this tag is self closing | ||
/// | ||
/// ``` | ||
/// use html_validation::is_self_closing; | ||
/// | ||
/// assert_eq!(is_self_closing("br"), true); | ||
/// | ||
/// assert_eq!(is_self_closing("div"), false); | ||
/// ``` | ||
pub fn is_self_closing(tag: &str) -> bool { | ||
SELF_CLOSING_TAGS.contains(tag) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6462688
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.
@ivanceras heads up - thanks!