Class: WebkitRemote::Client::DomNode

Inherits:
Object
  • Object
show all
Defined in:
lib/webkit_remote_unstable/css.rb

Instance Method Summary collapse

Instance Method Details

#computed_styleHash<Symbol, String>

Returns computed CSS attributes for this node.

Returns:

  • (Hash<Symbol, String>)

    computed CSS attributes for this node



42
43
44
# File 'lib/webkit_remote_unstable/css.rb', line 42

def computed_style
  @computed_style ||= computed_style!
end

#computed_style!Hash<Symbol, String>

Gets the node’s computed CSS attributes, bypassing the node cache.

Returns:

  • (Hash<Symbol, String>)

    computed CSS attributes for this node



49
50
51
52
53
54
# File 'lib/webkit_remote_unstable/css.rb', line 49

def computed_style!
  result = @client.rpc.call 'CSS.getComputedStyleForNode', nodeId: @remote_id
  @computed_style = Hash[result['computedStyle'].map { |property|
    [property['name'].gsub('-', '_').to_sym, property['value']]
  }]
end

#initialize_cssObject



57
58
59
# File 'lib/webkit_remote_unstable/css.rb', line 57

def initialize_css
  @computed_style = nil
end