Sha256: 46084b34a8fbd3c99eb58e4fa34d46491cd55e08157940b0ce8dbb6b06be6a54

Contents?: true

Size: 769 Bytes

Versions: 15

Compression:

Stored size: 769 Bytes

Contents

# backtick_javascript: true

module Browser
  module Document
    extend DelegateNative
    extend EventTarget

    @native = `document`

    module_function

    # @return [Browser::Element] the head element of the current document
    def head
      @head ||= Element.new(`#@native.head`)
    end

    # @return [Browser::Element] the body element of the current document
    def body
      @body ||= Element.new(`#@native.body`)
    end

    # @return [Browser::Element?] the first element that matches the given CSS
    #   selector or `nil` if no elements match
    def [] css
      native = `#@native.querySelector(css)`
      if `#{native} === null`
        nil
      else
        Element.new(native)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
isomorfeus-preact-23.9.0.rc12 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc11 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc10 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc9 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc8 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc7 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc6 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc5 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc4 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc3 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc2 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.9.0.rc1 lib/browser_auto/browser/document.rb
isomorfeus-preact-23.8.0.rc3 lib/browser/document.rb
isomorfeus-preact-23.8.0.rc2 lib/browser/document.rb
isomorfeus-preact-23.8.0.rc1 lib/browser/document.rb