Sha256: c3ab2e55e6b1f19d978de2afaec1e2648a61853d7fb7b5f83d6df87fd0b271bf

Contents?: true

Size: 607 Bytes

Versions: 14

Compression:

Stored size: 607 Bytes

Contents

module Hyalite::DOM
  class Document
    include Native
    include Node

    def create_element(tag)
      Element.new `self.native.createElement(tag)`
    end

    def create_text(text)
      Text.new `self.native.createTextNode(text)`
    end

    def body
      Body.new `self.native.body`
    end

    def ready(&block)
      `self.native.addEventListener('DOMContentLoaded', block)`
    end

    def self.singleton
      @singleton ||= self.new(`window.document`)
    end

    def document?
      true
    end

    def [](q)
      Collection.new `self.native.querySelectorAll(#{q})`
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hyalite-0.3.4 lib/hyalite/dom/document.rb
hyalite-0.3.2 lib/hyalite/dom/document.rb
hyalite-0.3.1 lib/hyalite/dom/document.rb
hyalite-0.3.0 lib/hyalite/dom/document.rb
hyalite-0.2.8 lib/hyalite/dom/document.rb
hyalite-0.2.7 lib/hyalite/dom/document.rb
hyalite-0.2.6 lib/hyalite/dom/document.rb
hyalite-0.2.5 lib/hyalite/dom/document.rb
hyalite-0.2.4 lib/hyalite/dom/document.rb
hyalite-0.2.3 lib/hyalite/dom/document.rb
hyalite-0.2.2 lib/hyalite/dom/document.rb
hyalite-0.2.1 lib/hyalite/dom/document.rb
hyalite-0.2.0 lib/hyalite/dom/document.rb
hyalite-0.1.1 client/hyalite/dom/document.rb