swc_xml_parser/parser/
open_elements_stack.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use crate::parser::RcNode;

pub struct OpenElementsStack {
    pub items: Vec<RcNode>,
}

impl OpenElementsStack {
    pub fn new() -> Self {
        OpenElementsStack {
            items: Vec::with_capacity(16),
        }
    }

    pub fn pop_until_tag_name_popped(&mut self, tag_name: &[&str]) -> Option<RcNode> {
        while let Some(node) = self.items.pop() {
            if tag_name.contains(&get_tag_name!(node)) {
                return Some(node);
            }
        }

        None
    }
}