<commit_before>module Browser; module CSS

class StyleSheet
  include Native::Base

  alias_native :disabled?, :disabled
  alias_native :href, :href
  alias_native :media, :media
  alias_native :title, :title
  alias_native :type, :type

  def owner
    DOM(`#@native.ownerNode`)
  end

  def parent
    Sheet.new(`#@native.parentStyleSheet`) if `#@native.parentStyleSheet != null`
  end

  def rules
    Native::Array.new(`#@native.cssRules`) { |e|
      Rule.new(e)
    }
  end
<commit_msg>css/style_sheet: also create one from a <style> element<commit_after>module Browser; module CSS

class StyleSheet
  include Native::Base

  def initialize(what)
    if what.is_a? DOM::Element
      super(`#{what.to_n}.sheet`)
    else
      super(what)
    end
  end

  alias_native :disabled?, :disabled
  alias_native :href, :href
  alias_native :media, :media
  alias_native :title, :title
  alias_native :type, :type

  def owner
    DOM(`#@native.ownerNode`)
  end

  def parent
    Sheet.new(`#@native.parentStyleSheet`) if `#@native.parentStyleSheet != null`
  end

  def rules
    Native::Array.new(`#@native.cssRules`) { |e|
      Rule.new(e)
    }
  end

{'fraction_non_alphanumeric': 0.12370242214532871, 'fraction_numerical': 0.0, 'mean_word_length': 3.5731225296442686, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7197664', 'n_tokens_mistral': 401, 'n_tokens_neox': 388, 'n_words': 97}