2007-07-05 00:36:59 +02:00
|
|
|
require 'html5/html5parser/phase'
|
2007-05-30 17:45:52 +02:00
|
|
|
|
2007-07-05 00:36:59 +02:00
|
|
|
module HTML5
|
2007-05-30 17:45:52 +02:00
|
|
|
class AfterBodyPhase < Phase
|
|
|
|
|
|
|
|
handle_end 'html'
|
|
|
|
|
|
|
|
def processComment(data)
|
|
|
|
# This is needed because data is to be appended to the <html> element
|
|
|
|
# here and not to whatever is currently open.
|
2007-08-30 19:19:10 +02:00
|
|
|
@tree.insert_comment(data, @tree.open_elements.first)
|
2007-05-30 17:45:52 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def processCharacters(data)
|
2007-09-10 05:26:19 +02:00
|
|
|
parse_error("unexpected-char-after-body")
|
2007-05-30 17:45:52 +02:00
|
|
|
@parser.phase = @parser.phases[:inBody]
|
|
|
|
@parser.phase.processCharacters(data)
|
|
|
|
end
|
|
|
|
|
|
|
|
def processStartTag(name, attributes)
|
2007-09-10 05:26:19 +02:00
|
|
|
parse_error("unexpected-start-tag-after-body", {"name" => name})
|
2007-05-30 17:45:52 +02:00
|
|
|
@parser.phase = @parser.phases[:inBody]
|
|
|
|
@parser.phase.processStartTag(name, attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
def endTagHtml(name)
|
2007-08-30 19:19:10 +02:00
|
|
|
if @parser.inner_html
|
2007-12-17 10:17:43 +01:00
|
|
|
parse_error "end-html-in-innerhtml"
|
2007-05-30 17:45:52 +02:00
|
|
|
else
|
|
|
|
# XXX: This may need to be done, not sure
|
2007-08-30 19:19:10 +02:00
|
|
|
# Don't set last_phase to the current phase but to the inBody phase
|
2007-05-30 17:45:52 +02:00
|
|
|
# instead. No need for extra parse errors if there's something after </html>.
|
|
|
|
# Try "<!doctype html>X</html>X" for instance.
|
2007-08-30 19:19:10 +02:00
|
|
|
@parser.last_phase = @parser.phase
|
|
|
|
@parser.phase = @parser.phases[:trailingEnd]
|
2007-05-30 17:45:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def endTagOther(name)
|
2007-09-10 05:26:19 +02:00
|
|
|
parse_error("unexpected-end-tag-after-body", {"name" => name})
|
2007-05-30 17:45:52 +02:00
|
|
|
@parser.phase = @parser.phases[:inBody]
|
|
|
|
@parser.phase.processEndTag(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|