1 parent
5182d0c488
commit
d0d597e2d9
6 files changed
+128
-28
No files matched your search
@@ -1,30 +1,46 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Oga::XML::Lexer do
|
||||
describe 'HTML tables' do
|
||||
describe 'with unclosed <tr> tags' do
|
||||
it 'lexes a <tr> tag followed by a <tbody> tag' do
|
||||
lex_html('<tr>foo<tbody></tbody>').should == [
|
||||
[:T_ELEM_NAME, 'tr', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_NAME, 'tbody', 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
describe 'using HTML <table> elements' do
|
||||
it 'lexes two unclosed <table> elements following each other as separate elements' do
|
||||
lex_html('<table>foo<table>bar').should == [
|
||||
[:T_ELEM_NAME, 'table', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_NAME, 'table', 1],
|
||||
[:T_TEXT, 'bar', 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes an unclosed <th> tag followed by a <tbody> tag' do
|
||||
lex_html('<tr><th>foo<tbody>bar</tbody>').should == [
|
||||
[:T_ELEM_NAME, 'tr', 1],
|
||||
[:T_ELEM_NAME, 'th', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_NAME, 'tbody', 1],
|
||||
[:T_TEXT, 'bar', 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
it 'lexes a <table> element containing a <thead> element' do
|
||||
lex_html('<table><thead>foo</thead></table>').should == [
|
||||
[:T_ELEM_NAME, 'table', 1],
|
||||
[:T_ELEM_NAME, 'thead', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <table> element containing a <script> element' do
|
||||
lex_html('<table><script>foo</script></table>').should == [
|
||||
[:T_ELEM_NAME, 'table', 1],
|
||||
[:T_ELEM_NAME, 'script', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <table> element containing a <template> element' do
|
||||
lex_html('<table><template>foo</template></table>').should == [
|
||||
[:T_ELEM_NAME, 'table', 1],
|
||||
[:T_ELEM_NAME, 'template', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -33,5 +33,25 @@ describe Oga::XML::Lexer do
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <tbody> element containing a <script> element' do
|
||||
lex_html('<tbody><script>foo</script></tbody>').should == [
|
||||
[:T_ELEM_NAME, 'tbody', 1],
|
||||
[:T_ELEM_NAME, 'script', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <tbody> element containing a <template> element' do
|
||||
lex_html('<tbody><template>foo</template></tbody>').should == [
|
||||
[:T_ELEM_NAME, 'tbody', 1],
|
||||
[:T_ELEM_NAME, 'template', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -33,5 +33,25 @@ describe Oga::XML::Lexer do
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <tfoot> element containing a <script> element' do
|
||||
lex_html('<tfoot><script>foo</script></tfoot>').should == [
|
||||
[:T_ELEM_NAME, 'tfoot', 1],
|
||||
[:T_ELEM_NAME, 'script', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <tfoot> element containing a <template> element' do
|
||||
lex_html('<tfoot><template>foo</template></tfoot>').should == [
|
||||
[:T_ELEM_NAME, 'tfoot', 1],
|
||||
[:T_ELEM_NAME, 'template', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -33,5 +33,25 @@ describe Oga::XML::Lexer do
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <thead> element containing a <script> element' do
|
||||
lex_html('<thead><script>foo</script></thead>').should == [
|
||||
[:T_ELEM_NAME, 'thead', 1],
|
||||
[:T_ELEM_NAME, 'script', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <thead> element containing a <template> element' do
|
||||
lex_html('<thead><template>foo</template></thead>').should == [
|
||||
[:T_ELEM_NAME, 'thead', 1],
|
||||
[:T_ELEM_NAME, 'template', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -32,5 +32,25 @@ describe Oga::XML::Lexer do
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <tr> element containing a <script> element' do
|
||||
lex_html('<tr><script>foo</script></tr>').should == [
|
||||
[:T_ELEM_NAME, 'tr', 1],
|
||||
[:T_ELEM_NAME, 'script', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
|
||||
it 'lexes a <tr> element containing a <template> element' do
|
||||
lex_html('<tr><template>foo</template></tr>').should == [
|
||||
[:T_ELEM_NAME, 'tr', 1],
|
||||
[:T_ELEM_NAME, 'template', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user