44 lines
944 B
Ruby
44 lines
944 B
Ruby
require "webrat/core_extensions/meta_class"
|
|
|
|
module Webrat
|
|
|
|
def self.nokogiri_document(stringlike) #:nodoc:
|
|
return stringlike.dom if stringlike.respond_to?(:dom)
|
|
|
|
if Nokogiri::HTML::Document === stringlike
|
|
stringlike
|
|
elsif Nokogiri::XML::NodeSet === stringlike
|
|
stringlike
|
|
elsif StringIO === stringlike
|
|
Nokogiri.parse(stringlike.string)
|
|
elsif stringlike.respond_to?(:body)
|
|
Nokogiri.parse(stringlike.body.to_s)
|
|
else
|
|
Nokogiri.parse(stringlike.to_s)
|
|
end
|
|
end
|
|
|
|
def self.define_dom_method(object, dom) #:nodoc:
|
|
object.meta_class.send(:define_method, :dom) do
|
|
dom
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
|
|
module Nokogiri #:nodoc:
|
|
module CSS #:nodoc:
|
|
class XPathVisitor #:nodoc:
|
|
|
|
def visit_pseudo_class_text(node) #:nodoc:
|
|
"@type='text'"
|
|
end
|
|
|
|
def visit_pseudo_class_password(node) #:nodoc:
|
|
"@type='password'"
|
|
end
|
|
|
|
end
|
|
end
|
|
end |