From 66030d5d810cc7124ea7165af673c18386a5b85e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Tue, 18 Aug 2015 09:40:14 +0200 Subject: [PATCH 1/2] Introduce rcdom::ElementEnum Used for data of elements with special behaviour when parsing. --- examples/print-rcdom.rs | 2 +- src/rcdom.rs | 43 ++++++++++++++++++++++++++--------------- tests/tree_builder.rs | 2 +- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/examples/print-rcdom.rs b/examples/print-rcdom.rs index 115794af..f4106204 100644 --- a/examples/print-rcdom.rs +++ b/examples/print-rcdom.rs @@ -44,7 +44,7 @@ fn walk(indent: usize, handle: Handle) { Comment(ref text) => println!("", escape_default(text)), - Element(ref name, ref attrs) => { + Element(ref name, _, ref attrs) => { assert!(name.ns == ns!(html)); print!("<{}", name.local); for attr in attrs.iter() { diff --git a/src/rcdom.rs b/src/rcdom.rs index 667c75ae..f315995a 100644 --- a/src/rcdom.rs +++ b/src/rcdom.rs @@ -32,8 +32,16 @@ use serialize::TraversalScope; use serialize::TraversalScope::{IncludeNode, ChildrenOnly}; use driver::ParseResult; +pub use self::ElementEnum::{Normal, Script}; pub use self::NodeEnum::{Document, Doctype, Text, Comment, Element}; +/// The different kinds of elements in the DOM. +#[derive(Debug)] +pub enum ElementEnum { + Normal, + Script(bool), +} + /// The different kinds of nodes in the DOM. #[derive(Debug)] pub enum NodeEnum { @@ -50,7 +58,7 @@ pub enum NodeEnum { Comment(StrTendril), /// An element with attributes. - Element(QualName, Vec), + Element(QualName, ElementEnum, Vec), } /// A DOM node. @@ -58,11 +66,6 @@ pub struct Node { pub node: NodeEnum, pub parent: Option, pub children: Vec, - - /// The "script already started" flag. - /// - /// Not meaningful for nodes other than HTML `