lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.2.0 vs lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.3.0

- old
+ new

@@ -26,17 +26,23 @@ currentUrl: -> window.location.toString() find: (method, selector, within = document) -> - if method == "xpath" - xpath = document.evaluate(selector, within, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) - results = (xpath.snapshotItem(i) for i in [0...xpath.snapshotLength]) - else - results = within.querySelectorAll(selector) + try + if method == "xpath" + xpath = document.evaluate(selector, within, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) + results = (xpath.snapshotItem(i) for i in [0...xpath.snapshotLength]) + else + results = within.querySelectorAll(selector) - this.register(el) for el in results + this.register(el) for el in results + catch error + if error.code == DOMException.SYNTAX_ERR + throw new PoltergeistAgent.InvalidSelector + else + throw error register: (element) -> @elements.push(element) @elements.length - 1 @@ -58,9 +64,12 @@ afterUpload: (id) -> this.get(id).removeAttribute('_poltergeist_selected') class PoltergeistAgent.ObsoleteNode toString: -> "PoltergeistAgent.ObsoleteNode" + +class PoltergeistAgent.InvalidSelector + toString: -> "PoltergeistAgent.InvalidSelector" class PoltergeistAgent.Node @EVENTS = { FOCUS: ['blur', 'focus', 'focusin', 'focusout'], MOUSE: ['click', 'dblclick', 'mousedown', 'mouseenter', 'mouseleave', 'mousemove',