lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.11.0 vs lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.12.0

- old
+ new

@@ -1,35 +1,17 @@ # This is injected into each page that is loaded - class PoltergeistAgent - # Since this code executes in the sites browser space - copy needed JSON functions - # in case user code messes with JSON (early mootools for instance) - @.JSON ||= { parse: JSON.parse, stringify: JSON.stringify } - constructor: -> @elements = [] @nodes = {} externalCall: (name, args) -> try { value: this[name].apply(this, args) } catch error { error: { message: error.toString(), stack: error.stack } } - @stringify: (object) -> - try - PoltergeistAgent.JSON.stringify object, (key, value) -> - if Array.isArray(this[key]) - return this[key] - else - return value - catch error - if error instanceof TypeError - '"(cyclic structure)"' - else - throw error - # Somehow PhantomJS returns all characters(brackets, etc) properly encoded # except whitespace character in pathname part of the location. This hack # is intended to fix this up. currentUrl: -> window.location.href.replace(/\ /g, '%20') @@ -192,10 +174,10 @@ getAttribute: (name) -> if name == 'checked' || name == 'selected' @element[name] else - @element.getAttribute(name) + @element.getAttribute(name) ? undefined scrollIntoView: -> @element.scrollIntoViewIfNeeded() #Sometimes scrollIntoViewIfNeeded doesn't seem to work, not really sure why. #Just calling scrollIntoView doesnt work either, however calling scrollIntoView