Class: Gammo::Parser::InSelectInTable

Inherits:
InsertionMode show all
Defined in:
lib/gammo/parser/insertion_mode/in_select_in_table.rb

Overview

Section 12.2.6.4.17.

Instance Attribute Summary

Attributes inherited from InsertionMode

#parser

Instance Method Summary collapse

Methods inherited from InsertionMode

#initialize, #process

Constructor Details

This class inherits a constructor from Gammo::Parser::InsertionMode

Instance Method Details

#default(_) ⇒ Object



41
42
43
# File 'lib/gammo/parser/insertion_mode/in_select_in_table.rb', line 41

def default(_)
  halt InSelect.new(parser).process
end

#end_tag_token(token) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gammo/parser/insertion_mode/in_select_in_table.rb', line 23

def end_tag_token(token)
  case token.tag
  when Tags::Caption, Tags::Table, Tags::Tbody, Tags::Tfoot, Tags::Thead, Tags::Tr, Tags::Td, Tags::Th
    if token.instance_of?(Tokenizer::EndTagToken) && !parser.element_in_scope?(TABLE_SCOPE, token.tag)
      # ignore the token
      halt true
    end
    parser.open_elements.reverse_each_with_index do |elm, i|
      if elm.tag == Tags::Select
        parser.open_elements = parser.open_elements.slice(0, i)
        break
      end
    end
    parser.reset_insertion_mode
    halt false
  end
end

#start_tag_token(token) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gammo/parser/insertion_mode/in_select_in_table.rb', line 5

def start_tag_token(token)
  case token.tag
  when Tags::Caption, Tags::Table, Tags::Tbody, Tags::Tfoot, Tags::Thead, Tags::Tr, Tags::Td, Tags::Th
    if token.instance_of?(Tokenizer::EndTagToken) && parser.element_in_scope?(TABLE_SCOPE, token.tag)
      # ignore the token
      halt true
    end
    parser.open_elements.reverse_each_with_index do |elm, i|
      if elm.tag == Tags::Select
        parser.open_elements = parser.open_elements.slice(0, i)
        break
      end
    end
    parser.reset_insertion_mode
    halt false
  end
end