Skip to content

Commit

Permalink
rename function name
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza1311 committed Nov 6, 2022
1 parent a498432 commit cb789f6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion examples/inner_html/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ impl Component for App {
}

fn view(&self, _ctx: &Context<Self>) -> Html {
Html::from_raw_html(HTML.into())
Html::from_html_unchecked(HTML.into())
}
}

Expand Down
34 changes: 17 additions & 17 deletions packages/yew/src/dom_bundle/braw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ mod tests {
let (root, scope, parent) = setup_parent();

const HTML: &str = "<span>text</span>";
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML)
Expand All @@ -176,7 +176,7 @@ mod tests {
let (root, scope, parent) = setup_parent();

const HTML: &str = "";
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML)
Expand All @@ -188,7 +188,7 @@ mod tests {

const HTML: &str =
r#"<p>one <a href="https://yew.rs">link</a> more paragraph</p><div>here</div>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML)
Expand All @@ -198,7 +198,7 @@ mod tests {
let (root, scope, parent) = setup_parent();

const HTML: &str = r#"<p>paragraph</p><a href="https://yew.rs">link</a>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML)
Expand All @@ -209,7 +209,7 @@ mod tests {
let (root, scope, parent) = setup_parent();

const HTML: &str = r#"<p>paragraph</p><a href="https://yew.rs">link</a>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML);
Expand All @@ -222,7 +222,7 @@ mod tests {
let (root, scope, parent) = setup_parent();

const HTML: &str = r#"<p>paragraph</p>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML);
Expand All @@ -235,7 +235,7 @@ mod tests {
let (root, scope, parent) = setup_parent();

const HTML: &str = "";
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML);
Expand All @@ -248,7 +248,7 @@ mod tests {
let (root, scope, parent, sibling) = setup_parent_and_sibling();

const HTML: &str = "<span>text</span>";
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -259,7 +259,7 @@ mod tests {
let (root, scope, parent, sibling) = setup_parent_and_sibling();

const HTML: &str = "";
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -271,7 +271,7 @@ mod tests {

const HTML: &str =
r#"<p>one <a href="https://yew.rs">link</a> more paragraph</p><div>here</div>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -281,7 +281,7 @@ mod tests {
let (root, scope, parent, sibling) = setup_parent_and_sibling();

const HTML: &str = r#"<p>paragraph</p><a href="https://yew.rs">link</a>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -292,7 +292,7 @@ mod tests {
let (root, scope, parent, sibling) = setup_parent_and_sibling();

const HTML: &str = r#"<p>paragraph</p><a href="https://yew.rs">link</a>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -305,7 +305,7 @@ mod tests {
let (root, scope, parent, sibling) = setup_parent_and_sibling();

const HTML: &str = r#"<p>paragraph</p>"#;
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -318,7 +318,7 @@ mod tests {
let (root, scope, parent, sibling) = setup_parent_and_sibling();

const HTML: &str = "";
let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -331,7 +331,7 @@ mod tests {
let (root, scope, parent) = setup_parent();
const HTML: &str = r#"<p>paragraph</p>"#;

let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML);
Expand All @@ -350,7 +350,7 @@ mod tests {
let (root, scope, parent, sibling) = setup_parent_and_sibling();
const HTML: &str = r#"<p>paragraph</p>"#;

let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, sibling);
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), format!("{}{}", HTML, SIBLING_CONTENT));
Expand All @@ -377,7 +377,7 @@ mod tests {
let (root, scope, parent) = setup_parent();
const HTML: &str = r#"<p>paragraph</p><a href="https://yew.rs">link</a>"#;

let elem = VNode::from_raw_html(HTML.into());
let elem = VNode::from_html_unchecked(HTML.into());
let (_, mut elem) = elem.attach(&root, &scope, &parent, NodeRef::default());
assert_braw(&mut elem);
assert_eq!(parent.inner_html(), HTML);
Expand Down
6 changes: 3 additions & 3 deletions packages/yew/src/virtual_dom/vnode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub enum VNode {
VSuspense(VSuspense),
/// A raw HTML string, represented by [`AttrValue`](crate::AttrValue).
///
/// Also see: [`VNode::from_raw_html`]
/// Also see: [`VNode::from_html_unchecked`]
VRaw(VRaw),
}

Expand Down Expand Up @@ -75,15 +75,15 @@ impl VNode {
/// ```rust
/// use yew::{html, AttrValue, Html};
/// # fn _main() {
/// let parsed = Html::from_raw_html(AttrValue::from("<div>content</div>"));
/// let parsed = Html::from_html_unchecked(AttrValue::from("<div>content</div>"));
/// let _: Html = html! {
/// <div>
/// {parsed}
/// </div>
/// };
/// # }
/// ```
pub fn from_raw_html(html: AttrValue) -> Self {
pub fn from_html_unchecked(html: AttrValue) -> Self {
VNode::VRaw(VRaw { html })
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/yew/tests/raw_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ macro_rules! create_test {
async fn $name() {
#[function_component]
fn App() -> Html {
let raw = Html::from_raw_html(AttrValue::from($raw));
let raw = Html::from_html_unchecked(AttrValue::from($raw));
html! {
<div id="raw-container">
{raw}
Expand Down Expand Up @@ -84,7 +84,7 @@ macro_rules! create_update_html_test {
let raw_html = raw_html.clone();
move |_| raw_html.set($updated)
};
let raw = Html::from_raw_html(AttrValue::from(*raw_html));
let raw = Html::from_html_unchecked(AttrValue::from(*raw_html));
html! {
<>
<div id="raw-container">
Expand Down Expand Up @@ -158,7 +158,7 @@ async fn change_vnode_types_from_other_to_vraw() {
let node = use_state(|| html!("text"));
let onclick = {
let node = node.clone();
move |_| node.set(Html::from_raw_html(AttrValue::from("<span>second</span>")))
move |_| node.set(Html::from_html_unchecked(AttrValue::from("<span>second</span>")))
};
html! {
<>
Expand Down Expand Up @@ -203,7 +203,7 @@ async fn change_vnode_types_from_other_to_vraw() {
async fn change_vnode_types_from_vraw_to_other() {
#[function_component]
fn App() -> Html {
let node = use_state(|| Html::from_raw_html(AttrValue::from("<span>second</span>")));
let node = use_state(|| Html::from_html_unchecked(AttrValue::from("<span>second</span>")));
let onclick = {
let node = node.clone();
move |_| node.set(html!("text"))
Expand Down

0 comments on commit cb789f6

Please sign in to comment.