From ce16075588de7a23c426af650f4cc8079719f501 Mon Sep 17 00:00:00 2001 From: Chris Paris Date: Wed, 1 Apr 2015 11:05:00 -1000 Subject: [PATCH] Replace spec quotes with spec step numbers --- components/script/dom/element.rs | 22 ++++++++-------------- components/script/parse/html.rs | 16 ++++------------ 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 37bf2d2ca23f..cc3a6304eb39 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1172,11 +1172,10 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } fn SetInnerHTML(self, value: DOMString) -> Fallible<()> { - // 1. Let fragment be the result of invoking the fragment parsing algorithm - // with the new value as markup, and the context object as the context element. - // 2. Replace all with fragment within the context object. let context_node: JSRef = NodeCast::from_ref(self); + // Step 1. let frag = try!(context_node.parse_fragment(value)); + // Step 2. Node::replace_all(Some(NodeCast::from_ref(frag.root().r())), context_node); Ok(()) } @@ -1188,22 +1187,18 @@ impl<'a> ElementMethods for JSRef<'a, Element> { fn SetOuterHTML(self, value: DOMString) -> Fallible<()> { let context_document = document_from_node(self).root(); let context_node: JSRef = NodeCast::from_ref(self); - // 1. Let parent be the context object's parent. + // Step 1. let context_parent = match context_node.parent_node() { - // 2. If parent is null, terminate these steps. + // Step 2. None => return Ok(()), Some(parent) => parent.root() }; let parent: Root = match context_parent.r().type_id() { - // 3. If parent is a Document, throw a DOMException - // with name "NoModificationAllowedError" exception. + // Step 3. NodeTypeId::Document => return Err(NoModificationAllowed), - // 4. If parent is a DocumentFragment, let parent be a new Element with - // body as its local name, - // The HTML namespace as its namespace, and - // The context object's node document as its node document. + // Step 4. NodeTypeId::DocumentFragment => { let body_elem = Element::create(QualName::new(ns!(HTML), atom!(body)), None, context_document.r(), @@ -1214,10 +1209,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> { _ => context_node.parent_node().unwrap().root() }; - // 5. Let fragment be the result of invoking the fragment parsing algorithm with - // the new value as markup, and parent as the context element. - // 6. Replace the context object with fragment within the context object's parent. + // Step 5. let frag = try!(parent.r().parse_fragment(value)); + // Step 6. try!(context_parent.r().ReplaceChild(NodeCast::from_ref(frag.root().r()), context_node)); Ok(()) diff --git a/components/script/parse/html.rs b/components/script/parse/html.rs index ad8c56ba613b..f6cf86bf1228 100644 --- a/components/script/parse/html.rs +++ b/components/script/parse/html.rs @@ -336,24 +336,16 @@ pub fn parse_html_fragment(context_node: JSRef, input: DOMString) -> Vec, input: DOMString) -> Vec = NodeCast::from_ref(root_element.r()); root_node.children()