Repository: jaytaph/gosub-browser
File: src/html5/parser.rs (Rust)

Code before:

    /// Retrieves a list of all errors generated by the parser/tokenizer
    pub fn get_parse_errors(&self) -> Vec<ParseError> {
        self.error_logger.borrow().get_errors().clone()
    }

    /// Send a parse error to the error logger
    fn parse_error(&self, message: &str) {
        self.error_logger
            .borrow_mut()
            .add_error(self.tokenizer.get_position(), message);
    }

    /// Create a new node that is not connected or attached to the document arena
    fn create_node(&self, token: &Token, namespace: &str) -> Node {
        match token {
            Token::DocType {
                name,
                pub_identifier,
                sys_identifier,
                ..
            } => Node::new_doctype(
                &self.document,
                &name.clone().unwrap_or("".into()),
                &pub_identifier.clone().unwrap_or("".into()),
                &sys_identifier.clone().unwrap_or("".into()),
            ),
            Token::StartTag {
                name, attributes, ..
            } => Node::new_element(&self.document, name, attributes.clone(), namespace),
            Token::EndTag { name, .. } => {
                Node::new_element(&self.document, name, HashMap::new(), namespace)
            }
            Token::Comment(value) => Node::new_comment(&self.document, value),
            Token::Text(value) => Node::new_text(&self.document, value.to_string().as_str()),
            Token::Eof => {
                panic!("EOF token not allowed");
            }
        }
    }

    fn flush_pending_table_character_tokens(&mut self) {
        todo!()
    }

    /// This function will pop elements off the stack until it reaches the first element that matches
    /// our condition (which can be changed with the except and thoroughly parameters)
    fn generate_implied_end_tags(&mut self, except: Option<&str>, thoroughly: bool) {
        loop {
            if self.open_elements.is_empty() {
                return;

Review comment (suggestion):
```suggestion
                &name.clone().unwrap_or_default(),
                &pub_identifier.clone().unwrap_or_default(),
                &sys_identifier.clone().unwrap_or_default(),
```

Code after:

    /// Retrieves a list of all errors generated by the parser/tokenizer
    pub fn get_parse_errors(&self) -> Vec<ParseError> {
        self.error_logger.borrow().get_errors().clone()
    }

    /// Send a parse error to the error logger
    fn parse_error(&self, message: &str) {
        self.error_logger
            .borrow_mut()
            .add_error(self.tokenizer.get_position(), message);
    }

    /// Create a new node that is not connected or attached to the document arena
    fn create_node(&self, token: &Token, namespace: &str) -> Node {
        match token {
            Token::DocType {
                name,
                pub_identifier,
                sys_identifier,
                ..
            } => Node::new_doctype(
                &self.document,
                &name.clone().unwrap_or_default(),
                &pub_identifier.clone().unwrap_or_default(),
                &sys_identifier.clone().unwrap_or_default(),
            ),
            Token::StartTag {
                name, attributes, ..
            } => Node::new_element(&self.document, name, attributes.clone(), namespace),
            Token::EndTag { name, .. } => {
                Node::new_element(&self.document, name, HashMap::new(), namespace)
            }
            Token::Comment(value) => Node::new_comment(&self.document, value),
            Token::Text(value) => Node::new_text(&self.document, value.to_string().as_str()),
            Token::Eof => {
                panic!("EOF token not allowed");
            }
        }
    }

    fn flush_pending_table_character_tokens(&mut self) {
        todo!()
    }

    /// This function will pop elements off the stack until it reaches the first element that matches
    /// our condition (which can be changed with the except and thoroughly parameters)
    fn generate_implied_end_tags(&mut self, except: Option<&str>, thoroughly: bool) {
        loop {
            if self.open_elements.is_empty() {
                return;