lib/watir/dom/elements/element.rb in watir-dom-wait-0.2.0 vs lib/watir/dom/elements/element.rb in watir-dom-wait-0.2.1
- old
+ new
@@ -20,39 +20,35 @@
#
# @example With 5 seconds delay of how long to waiting for DOM to start modifying
# browser.div(id: 'test').when_dom_changed(delay: 5).a(id: 'link').click
#
# @param [Hash] opts
- # @option opts [Fixnum] timeout seconds to wait before timing out
# @option opts [Float] interval How long to wait between DOM nodes adding/removing in seconds. Defaults to 0.5
- # @option opts [Float] delay How long to wait for DOM modifications to start in seconds. Defaults to 1
+ # @option opts [Float] delay How long to wait for DOM modifications to start
+ # @option opts [Fixnum] timeout seconds to wait before timing out
#
def when_dom_changed(opts = {})
message = "waiting for DOM subtree to finish modifying in #{selector_string}"
- opts[:timeout] ||= Dom::Wait.timeout
opts[:interval] ||= Dom::Wait.interval
opts[:delay] ||= Dom::Wait.delay
+ opts[:timeout] ||= Dom::Wait.timeout
- Dom::Wait.rescue do
- if block_given?
- js = Dom::Wait::JAVASCRIPT.dup
- browser.execute_script js, self, opts[:interval], opts[:delay]
- Wait.until(opts[:timeout], message) { browser.execute_script(Dom::Wait::DOM_READY) == 0 }
- yield self
- else
- WhenDOMChangedDecorator.new(self, opts, message)
- end
+ if block_given?
+ Dom::Wait.wait_for_dom(self, opts, message)
+ yield self
+ else
+ WhenDOMChangedDecorator.new(self, opts, message)
end
end
#
# Waits until DOM is changed within the element.
#
# @param [Hash] opts
- # @option opts [Fixnum] timeout seconds to wait before timing out
# @option opts [Float] interval How long to wait between DOM nodes adding/removing in seconds. Defaults to 0.5
- # @option opts [Float] delay How long to wait for DOM modifications to start in seconds. Defaults to 1
+ # @option opts [Float] delay How long to wait for DOM modifications to start
+ # @option opts [Fixnum] timeout seconds to wait before timing out
#
def wait_until_dom_changed(opts = {})
when_dom_changed(opts) do
# just trigger waiting