Class: DOM::Style

Inherits:
Object show all
Defined in:
opal/fron/dom/style.rb

Overview

Style

Instance Method Summary collapse

Constructor Details

#initialize(el) ⇒ Style

Initializes the style


9
10
11
# File 'opal/fron/dom/style.rb', line 9

def initialize(el)
  @el = el
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, value) ⇒ String

Sets or gets a given CSS property


19
20
21
22
23
24
25
# File 'opal/fron/dom/style.rb', line 19

def method_missing(name, value)
  if name =~ /\=$/
    self[name[0..-2]] = value
  else
    self[name]
  end
end

Instance Method Details

#[](prop) ⇒ String

Gets a CSS property value


32
33
34
# File 'opal/fron/dom/style.rb', line 32

def [](prop)
  `#{@el}.style[#{prop}]`
end

#[]=(prop, value) ⇒ Object

Sets the given CSS property with the given value


40
41
42
# File 'opal/fron/dom/style.rb', line 40

def []=(prop, value)
  `#{@el}.style[#{prop}] = #{value}`
end