Class: Browser::DOM::MutationObserver::Record

Inherits:
Object
  • Object
show all
Includes:
NativeCachedWrapper
Defined in:
opal/browser/dom/mutation_observer.rb

Overview

Encapsulates a recorded change.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from NativeCachedWrapper

#restricted?, #set_native_reference

Instance Attribute Details

#addedNodeSet (readonly)

Returns the added nodes.

Returns:



46
47
48
49
50
51
52
53
54
# File 'opal/browser/dom/mutation_observer.rb', line 46

def added
  array = if `#@native.addedNodes != null`
    Native::Array.new(`#@native.addedNodes`)
  else
    []
  end

  NodeSet[array]
end

#nameString (readonly)

Returns the name of the attribute.

Returns:

  • (String)

    the name of the attribute



80
# File 'opal/browser/dom/mutation_observer.rb', line 80

alias_native :name, :attributeName

#namespaceString (readonly)

Returns the namespace of the attribute.

Returns:

  • (String)

    the namespace of the attribute



84
# File 'opal/browser/dom/mutation_observer.rb', line 84

alias_native :namespace, :attributeNamespace

#oldString (readonly)

Returns the old value.

Returns:



76
# File 'opal/browser/dom/mutation_observer.rb', line 76

alias_native :old, :oldValue

#removedNodeSet (readonly)

Returns the removed nodes.

Returns:



58
59
60
61
62
63
64
65
66
# File 'opal/browser/dom/mutation_observer.rb', line 58

def removed
  array = if `#@native.removedNodes != null`
    Native::Array.new(`#@native.removedNodes`)
  else
    []
  end

  NodeSet[array]
end

#targetNode (readonly)

Returns the node the mutation affected.

Returns:

  • (Node)

    the node the mutation affected



70
71
72
# File 'opal/browser/dom/mutation_observer.rb', line 70

def target
  DOM(`#@native.target`)
end

#type:attributes, ... (readonly)

Returns the type of the recorded change.

Returns:

  • (:attributes, :tree, :cdata)

    the type of the recorded change



21
22
23
24
25
26
27
# File 'opal/browser/dom/mutation_observer.rb', line 21

def type
  case `#@native.type`
  when :attributes    then :attribute
  when :childList     then :tree
  when :characterData then :cdata
  end
end

Instance Method Details

#attribute?Boolean

Returns true if the change happened on attributes.

Returns:

  • (Boolean)


30
31
32
# File 'opal/browser/dom/mutation_observer.rb', line 30

def attribute?
  type == :attribute
end

#cdata?Boolean

Returns true if the change happened in a CDATA section.

Returns:

  • (Boolean)


40
41
42
# File 'opal/browser/dom/mutation_observer.rb', line 40

def cdata?
  type == :cdata
end

#tree?Boolean

Returns true if the change happened on the tree.

Returns:

  • (Boolean)


35
36
37
# File 'opal/browser/dom/mutation_observer.rb', line 35

def tree?
  type == :tree
end