Sha256: b6e00fa50ffd72bc3b399eb4cc27a85f91b43ff28eee731128d5cbe0c9c71ae2

Contents?: true

Size: 738 Bytes

Versions: 21

Compression:

Stored size: 738 Bytes

Contents

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

21 entries across 21 versions & 1 rubygems

Version Path
isomorfeus-preact-23.7.0.rc5 lib/browser/document.rb
isomorfeus-preact-23.7.0.rc4 lib/browser/document.rb
isomorfeus-preact-23.7.0.rc3 lib/browser/document.rb
isomorfeus-preact-23.7.0.rc2 lib/browser/document.rb
isomorfeus-preact-23.7.0.rc1 lib/browser/document.rb
isomorfeus-preact-23.6.0.rc5 lib/browser/document.rb
isomorfeus-preact-23.6.0.rc4 lib/browser/document.rb
isomorfeus-preact-23.6.0.rc3 lib/browser/document.rb
isomorfeus-preact-23.6.0.rc2 lib/browser/document.rb
isomorfeus-preact-23.6.0.rc1 lib/browser/document.rb
isomorfeus-preact-23.1.0.rc2 lib/browser/document.rb
isomorfeus-preact-23.1.0.rc1 lib/browser/document.rb
isomorfeus-preact-22.11.0.rc1 lib/browser/document.rb
isomorfeus-preact-22.10.0.rc2 lib/browser/document.rb
isomorfeus-preact-22.10.0.rc1 lib/browser/document.rb
isomorfeus-preact-22.9.0.rc9 lib/browser/document.rb
isomorfeus-preact-22.9.0.rc8 lib/browser/document.rb
isomorfeus-preact-22.9.0.rc7 lib/browser/document.rb
isomorfeus-preact-22.9.0.rc6 lib/browser/document.rb
isomorfeus-preact-22.9.0.rc5 lib/browser/document.rb