Class: Dommy::MutationRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/observer.rb

Overview

MutationRecord — produced for childList, attributes, or characterData mutations and delivered to the observer callback. Mirrors the browser MutationRecord interface; ‘oldValue` is only populated when the observer asked for it via `attributeOldValue` / `characterDataOldValue`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, target:, added_nodes: [], removed_nodes: [], previous_sibling: nil, next_sibling: nil, attribute_name: nil, attribute_namespace: nil, old_value: nil) ⇒ MutationRecord

Returns a new instance of MutationRecord.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/dommy/observer.rb', line 12

def initialize(
  type:,
  target:,
  added_nodes: [],
  removed_nodes: [],
  previous_sibling: nil,
  next_sibling: nil,
  attribute_name: nil,
  attribute_namespace: nil,
  old_value: nil
)
  @type = type
  @target = target
  @added_nodes = added_nodes
  @removed_nodes = removed_nodes
  @previous_sibling = previous_sibling
  @next_sibling = next_sibling
  @attribute_name = attribute_name
  @attribute_namespace = attribute_namespace
  @old_value = old_value
end

Instance Attribute Details

#added_nodesObject (readonly)

Returns the value of attribute added_nodes.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def added_nodes
  @added_nodes
end

#attribute_nameObject (readonly)

Returns the value of attribute attribute_name.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def attribute_name
  @attribute_name
end

#attribute_namespaceObject (readonly)

Returns the value of attribute attribute_namespace.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def attribute_namespace
  @attribute_namespace
end

#next_siblingObject (readonly)

Returns the value of attribute next_sibling.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def next_sibling
  @next_sibling
end

#old_valueObject (readonly)

Returns the value of attribute old_value.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def old_value
  @old_value
end

#previous_siblingObject (readonly)

Returns the value of attribute previous_sibling.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def previous_sibling
  @previous_sibling
end

#removed_nodesObject (readonly)

Returns the value of attribute removed_nodes.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def removed_nodes
  @removed_nodes
end

#targetObject (readonly)

Returns the value of attribute target.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def target
  @target
end

#typeObject (readonly)

Returns the value of attribute type.



34
35
36
# File 'lib/dommy/observer.rb', line 34

def type
  @type
end

Instance Method Details

#__js_get__(key) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/dommy/observer.rb', line 46

def __js_get__(key)
  case key
  when "type"
    @type
  when "target"
    @target
  when "addedNodes"
    @added_nodes
  when "removedNodes"
    @removed_nodes
  when "previousSibling"
    @previous_sibling
  when "nextSibling"
    @next_sibling
  when "attributeName"
    @attribute_name
  when "attributeNamespace"
    @attribute_namespace
  when "oldValue"
    @old_value
  end
end