The HTML serializer depth can change on each iteration.

This commit is contained in:
Josh Matthews 2015-02-22 12:44:48 -05:00
parent e68d6d2924
commit 4c67acfb4a
3 changed files with 79 additions and 75 deletions

View file

@ -21,8 +21,8 @@ use std::borrow::ToOwned;
pub fn serialize(iterator: &mut NodeIterator) -> String {
let mut html = String::new();
let mut open_elements: Vec<String> = vec!();
let depth = iterator.depth;
for node in iterator {
while let Some(node) = iterator.next() {
let depth = iterator.depth;
while open_elements.len() > depth {
html.push_str("</");
html.push_str(open_elements.pop().unwrap().as_slice());