Sha256: 0d4856340153e3e307459752ce16084086cc476de16eb50fdb002d30cfe9077e
Contents?: true
Size: 795 Bytes
Versions: 1
Compression:
Stored size: 795 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) elements = [] %x( var nodeList = self.native.querySelectorAll(#{q}); for (var i = 0; i < nodeList.length; i++) { elements.$push(nodeList.item(i)); } ) elements.map!{|el| Element.new(el) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hyalite-0.1.0 | client/hyalite/dom/document.rb |