HTML closing specs for the "body" element

This commit is contained in:
Yorick Peterse 2015-05-18 21:44:00 +02:00
parent 688a1fff0e
commit efeb38699a
2 changed files with 38 additions and 1 deletions

View File

@ -0,0 +1,37 @@
require 'spec_helper'
describe Oga::XML::Lexer do
describe 'using HTML <body> elements' do
it 'lexes an unclosed <body> followed by a <head> as separate elements' do
lex_html('<body>foo<head>bar').should == [
[:T_ELEM_NAME, 'body', 1],
[:T_TEXT, 'foo', 1],
[:T_ELEM_END, nil, 1],
[:T_ELEM_NAME, 'head', 1],
[:T_TEXT, 'bar', 1],
[:T_ELEM_END, nil, 1]
]
end
it 'lexes an unclosed <body> followed by a <body> as separate elements' do
lex_html('<body>foo<body>bar').should == [
[:T_ELEM_NAME, 'body', 1],
[:T_TEXT, 'foo', 1],
[:T_ELEM_END, nil, 1],
[:T_ELEM_NAME, 'body', 1],
[:T_TEXT, 'bar', 1],
[:T_ELEM_END, nil, 1]
]
end
it 'lexes a <p> following an unclosed <body> as a child element' do
lex_html('<body><p>foo</body>').should == [
[:T_ELEM_NAME, 'body', 1],
[:T_ELEM_NAME, 'p', 1],
[:T_TEXT, 'foo', 1],
[:T_ELEM_END, nil, 1],
[:T_ELEM_END, nil, 1]
]
end
end
end

View File

@ -24,7 +24,7 @@ describe Oga::XML::Lexer do
]
end
it 'lexes a <title> followed an unclosed <head> as a child element' do
it 'lexes a <title> following an unclosed <head> as a child element' do
lex_html('<head><title>foo</title>').should == [
[:T_ELEM_NAME, 'head', 1],
[:T_ELEM_NAME, 'title', 1],