Added XML::Document#html?
This commit is contained in:
parent
ba2177e2cf
commit
9a586363e9
|
|
@ -77,6 +77,13 @@ module Oga
|
||||||
return xml
|
return xml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# @return [TrueClass|FalseClass]
|
||||||
|
#
|
||||||
|
def html?
|
||||||
|
return type == :html
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Inspects the document and its child nodes. Child nodes are indented for
|
# Inspects the document and its child nodes. Child nodes are indented for
|
||||||
# each nesting level.
|
# each nesting level.
|
||||||
|
|
|
||||||
|
|
@ -307,7 +307,7 @@ module Oga
|
||||||
self_closing = children.empty?
|
self_closing = children.empty?
|
||||||
root = root_node
|
root = root_node
|
||||||
|
|
||||||
if root.is_a?(Document) and root.type == :html \
|
if root.is_a?(Document) and root.html? \
|
||||||
and !HTML_VOID_ELEMENTS.include?(name)
|
and !HTML_VOID_ELEMENTS.include?(name)
|
||||||
self_closing = false
|
self_closing = false
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,16 @@ describe Oga::XML::Document do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#html?' do
|
||||||
|
it 'returns false for an XML document' do
|
||||||
|
described_class.new(:type => :xml).html?.should == false
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns true for an HTML document' do
|
||||||
|
described_class.new(:type => :html).html?.should == true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#inspect' do
|
describe '#inspect' do
|
||||||
before do
|
before do
|
||||||
@instance = described_class.new(
|
@instance = described_class.new(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue