class Gammo::Parser::InSelect

Section 12.2.6.4.16.

Public Instance Methods

comment_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/in_select.rb, line 59
def comment_token(token)
  parser.add_child(Node::Comment.new(data: token.data))
end
default(_) click to toggle source
# File lib/gammo/parser/insertion_mode/in_select.rb, line 72
def default(_)
  halt true
end
doctype_token(_) click to toggle source
# File lib/gammo/parser/insertion_mode/in_select.rb, line 63
def doctype_token(_)
  # ignore the token.
  halt true
end
end_tag_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/in_select.rb, line 37
def end_tag_token(token)
  case token.tag
  when Tags::Option
    parser.open_elements.pop if parser.top.tag == Tags::Option
    nil
  when Tags::Optgroup
    i = parser.open_elements.length - 1
    i -= 1 if parser.open_elements[i].tag == Tags::Option
    if parser.open_elements[i].tag == Tags::Optgroup
      parser.open_elements = parser.open_elements.slice(0, i)
    end
    nil
  when Tags::Select
    # ignore the token
    halt true unless parser.pop_until(SELECT_SCOPE, Tags::Select)
    parser.reset_insertion_mode
    nil
  when Tags::Template
    halt InHead.new(parser).process
  end
end
error_token(_) click to toggle source
# File lib/gammo/parser/insertion_mode/in_select.rb, line 68
def error_token(_)
  halt InBody.new(parser).process
end
start_tag_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/in_select.rb, line 9
def start_tag_token(token)
  case token.tag
  when Tags::Html
    halt InBody.new(parser).process
  when Tags::Option
    parser.open_elements.pop if parser.top.tag == Tags::Option
    parser.add_element
  when Tags::Optgroup
    parser.open_elements.pop if parser.top.tag == Tags::Option
    parser.open_elements.pop if parser.top.tag == Tags::Optgroup
    parser.add_element
  when Tags::Select
    # ignore the token
    halt true unless parser.pop_until(SELECT_SCOPE, Tags::Select)
    parser.reset_insertion_mode
  when Tags::Input, Tags::Keygen, Tags::Textarea
    if parser.element_in_scope?(SELECT_SCOPE, Tags::Select)
      parser.parse_implied_token(Tokenizer::EndTagToken, Tags::Select, Tags::Select.to_s)
      halt false
    end
    parser.tokenizer.next_is_not_raw_text!
    # ignore the token
    halt true
  when Tags::Script, Tags::Template
    halt InHead.new(parser).process
  end
end
text_token(token) click to toggle source
# File lib/gammo/parser/insertion_mode/in_select.rb, line 5
def text_token(token)
  parser.add_text token.data.gsub("\x00",'')
end