Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/gammo/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def index_of_element_in_scope(scope, *match_tags)
when TABLE_SCOPE
return -1 if tag == Tags::Html || tag == Tags::Table || tag == Tags::Template
when SELECT_SCOPE
return -1 if tag == Tags::Optgroup && tag == Tags::Option
return -1 if tag == Tags::Optgroup || tag == Tags::Option
else
raise ParseError, 'unreachable parsing error, please report to github'
end
Expand Down
23 changes: 23 additions & 0 deletions test/select_scope_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'test_helper'

class SelectScopeTest < Test::Unit::TestCase
include Support::Dump

test 'option and optgroup nesting' do
html = '<select><option>One<optgroup><option>Two</option></optgroup></select>'
doc = Gammo.new(html).parse
assert_equal(<<~OUT, dump_for(doc))
| <html>
| <head>
| <body>
| <select>
| <option>
| "One"
| <optgroup>
| <option>
| "Two"
OUT
)
end
end

Loading