Sha256: 5dc321b2aad8e66713086ffdfbe3ad9c919f2e273ca8e767eba52ef2b5594eb6

Contents?: true

Size: 746 Bytes

Versions: 2

Compression:

Stored size: 746 Bytes

Contents

module OpalSpec
  class Element
    def self.body_ready?
      `!!(document && document.body)`
    end

    def initialize(tag = 'div')
      `this.el = document.createElement(tag)`
    end

    def class_name=(class_name)
      `this.el.className = class_name`
    end

    def html=(html)
      `this.el.innerHTML = html`
    end

    def append(child)
      `this.el.appendChild(child.el)`
    end

    def hide
      `this.el.style.display = 'none'`
    end

    def show
      `delete this.el.style.display`
    end

    def append_to_head
      `document.head.appendChild(this.el)`
    end

    def append_to_body
      `document.body.appendChild(this.el)`
    end

    def style(key, val)
      `this.el.style[key] = val`
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-spec-0.1.5 lib/opal-spec/dom.rb
opal-spec-0.1.1 lib/opal-spec/dom.rb