Class: Deface::Actions::InsertTop

Inherits:
ElementAction show all
Defined in:
lib/deface/actions/insert_top.rb

Instance Attribute Summary

Attributes inherited from ElementAction

#source_element

Instance Method Summary collapse

Methods inherited from ElementAction

#initialize

Methods inherited from Action

#initialize, #range_compatible?, to_sym

Constructor Details

This class inherits a constructor from Deface::Actions::ElementAction

Instance Method Details

#execute(target_element) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/deface/actions/insert_top.rb', line 4

def execute(target_element)
  target_element = target_element.first
  if target_element.children.size == 0
    target_element.children = source_element
  else
    target_element.children.before(source_element)
  end
end