Sha256: c2b7b25326f02d885d33fc508e0f4e26104b2863083bc351f6659d9dccc77a1d

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 KB

Contents

module Browser; module CSS

class Rule
  include Browser::NativeCachedWrapper

  STYLE_RULE               = 1
  CHARSET_RULE             = 2
  IMPORT_RULE              = 3
  MEDIA_RULE               = 4
  FONT_FACE_RULE           = 5
  PAGE_RULE                = 6
  KEYFRAMES_RULE           = 7
  KEYFRAME_RULE            = 8
  NAMESPACE_RULE           = 10
  COUNTER_STYLE_RULE       = 11
  SUPPORTS_RULE            = 12
  DOCUMENT_RULE            = 13
  FONT_FEATURE_VALUES_RULE = 14
  VIEWPORT_RULE            = 15
  REGION_STYLE_RULE        = 16

  def self.new(rule)
    if self == Rule
      @classes ||= [nil, Style]

      if klass = @classes[`rule.type`]
        klass.new(rule)
      else
        raise ArgumentError, 'cannot instantiate a non derived Rule object'
      end
    else
      super(rule)
    end
  end

  alias_native :text, :cssText
  alias_native :to_s, :cssText

  def parent
    Rule.new(`#@native.parentRule`) if `#@native.parentRule != null`
  end

  def style_sheet
    StyleSheet.new(`#@native.parentStyleSheet`) if `#@native.parentStyleSheet != null`
  end
end

end; end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
opal-browser-0.3.4 opal/browser/css/rule.rb
atome-opal-browser-0.3.9.5 opal/browser/css/rule.rb
opal-browser-0.3.3 opal/browser/css/rule.rb
opal-browser-0.3.2 opal/browser/css/rule.rb
opal-browser-0.3.1 opal/browser/css/rule.rb
opal-browser-0.3.0 opal/browser/css/rule.rb