lib/capybara/poltergeist/client/compiled/agent.js in poltergeist-1.13.0 vs lib/capybara/poltergeist/client/compiled/agent.js in poltergeist-1.14.0

- old
+ new

@@ -1,6 +1,8 @@ -var PoltergeistAgent; +var PoltergeistAgent, + indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, + hasProp = {}.hasOwnProperty; PoltergeistAgent = (function() { function PoltergeistAgent() { this.elements = []; this.nodes = {}; @@ -98,10 +100,48 @@ PoltergeistAgent.prototype.clearLocalStorage = function() { return typeof localStorage !== "undefined" && localStorage !== null ? localStorage.clear() : void 0; }; + PoltergeistAgent.prototype.wrapResults = function(result, page_id) { + var j, key, len, obj, res, results1, val; + this._visitedObjects || (this._visitedObjects = []); + switch (false) { + case indexOf.call(this._visitedObjects, result) < 0: + return '(cyclic structure)'; + case !(Array.isArray(result) || (result instanceof NodeList)): + results1 = []; + for (j = 0, len = result.length; j < len; j++) { + res = result[j]; + results1.push(this.wrapResults(res, page_id)); + } + return results1; + break; + case !(result && result.nodeType === 1 && result['tagName']): + return { + 'ELEMENT': { + id: this.register(result), + page_id: page_id + } + }; + case !(result == null): + return void 0; + case typeof result !== 'object': + this._visitedObjects.push(result); + obj = {}; + for (key in result) { + if (!hasProp.call(result, key)) continue; + val = result[key]; + obj[key] = this.wrapResults(val, page_id); + } + this._visitedObjects.pop(); + return obj; + default: + return result; + } + }; + return PoltergeistAgent; })(); PoltergeistAgent.ObsoleteNode = (function() { @@ -160,10 +200,10 @@ Node.prototype.isObsolete = function() { var obsolete; obsolete = (function(_this) { return function(element) { var parent; - if ((parent = element.parentNode) != null) { + if ((parent = element != null ? element.parentNode : void 0) != null) { if (parent === document) { return false; } else { return obsolete(parent); }