terminus 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. data/bin/terminus +5 -5
  2. data/lib/capybara/driver/terminus.rb +24 -13
  3. data/lib/terminus.rb +21 -15
  4. data/lib/terminus/application.rb +6 -6
  5. data/lib/terminus/browser.rb +77 -60
  6. data/lib/terminus/client.rb +33 -16
  7. data/lib/terminus/client/browser.rb +10 -9
  8. data/lib/terminus/client/phantom.js +25 -3
  9. data/lib/terminus/client/phantomjs.rb +44 -7
  10. data/lib/terminus/connector.rb +2 -2
  11. data/lib/terminus/connector/server.rb +15 -15
  12. data/lib/terminus/connector/socket_handler.rb +11 -11
  13. data/lib/terminus/controller.rb +62 -26
  14. data/lib/terminus/headers.rb +25 -0
  15. data/lib/terminus/host.rb +6 -6
  16. data/lib/terminus/node.rb +36 -22
  17. data/lib/terminus/proxy.rb +81 -45
  18. data/lib/terminus/proxy/driver_body.rb +14 -15
  19. data/lib/terminus/proxy/external.rb +12 -6
  20. data/lib/terminus/proxy/rewrite.rb +7 -6
  21. data/lib/terminus/public/compiled/terminus-min.js +3 -3
  22. data/lib/terminus/public/compiled/terminus.js +225 -180
  23. data/lib/terminus/public/pathology.js +87 -87
  24. data/lib/terminus/public/terminus.js +138 -93
  25. data/lib/terminus/server.rb +7 -7
  26. data/lib/terminus/timeouts.rb +8 -8
  27. data/lib/terminus/views/bootstrap.erb +7 -7
  28. data/lib/terminus/views/index.erb +4 -4
  29. data/lib/terminus/views/infinite.html +4 -4
  30. data/spec/1.1/reports/android.txt +874 -0
  31. data/spec/{reports → 1.1/reports}/chrome.txt +72 -69
  32. data/spec/{reports → 1.1/reports}/firefox.txt +72 -69
  33. data/spec/{reports → 1.1/reports}/opera.txt +72 -69
  34. data/spec/{reports → 1.1/reports}/phantomjs.txt +72 -69
  35. data/spec/{reports → 1.1/reports}/safari.txt +72 -69
  36. data/spec/{spec_helper.rb → 1.1/spec_helper.rb} +5 -2
  37. data/spec/{terminus_driver_spec.rb → 1.1/terminus_driver_spec.rb} +2 -2
  38. data/spec/{terminus_session_spec.rb → 1.1/terminus_session_spec.rb} +2 -2
  39. data/spec/2.0/reports/android.txt +815 -0
  40. data/spec/2.0/reports/chrome.txt +806 -0
  41. data/spec/2.0/reports/firefox.txt +812 -0
  42. data/spec/2.0/reports/opera.txt +806 -0
  43. data/spec/2.0/reports/phantomjs.txt +803 -0
  44. data/spec/2.0/reports/safari.txt +806 -0
  45. data/spec/2.0/spec_helper.rb +21 -0
  46. data/spec/2.0/terminus_spec.rb +25 -0
  47. metadata +41 -32
  48. data/spec/reports/android.txt +0 -875
@@ -5,20 +5,20 @@ var Pathology = {
5
5
  expression.evaluate(context, context, resultType, result);
6
6
  return result;
7
7
  },
8
-
8
+
9
9
  atomize: function(expression, context, root) {
10
10
  var result = expression.evaluate(context, root);
11
11
  if (result && result.atomize) result = result.atomize();
12
12
  return result;
13
13
  },
14
-
14
+
15
15
  array: function(list) {
16
16
  if (!list) return [];
17
17
  var array = [], i = list.length;
18
18
  while (i--) array[i] = list[i];
19
19
  return array;
20
20
  },
21
-
21
+
22
22
  indexOf: function(list, item) {
23
23
  if (list.indexOf) return list.indexOf(item);
24
24
  for (var i = 0, n = list.length; i < n; i++) {
@@ -85,17 +85,17 @@ Pathology.XPathResult.prototype.atomize = function() {
85
85
  Pathology.XPathResult.prototype.makeString = function() {
86
86
  var first = this._nodes[0];
87
87
  if (!first) return '';
88
-
88
+
89
89
  switch (first.nodeType) {
90
90
  case XPathResult.STRING_TYPE:
91
91
  return this.atomize();
92
-
92
+
93
93
  case XPathResult.BOOLEAN_TYPE:
94
94
  var parts = [];
95
95
  for (var i = 0, n = this._nodes.length; i < n; i++)
96
96
  parts.push(this._nodes[i].nodeValue);
97
97
  return parts.join('');
98
-
98
+
99
99
  default:
100
100
  var result = document.evaluate('//text()', first, null, XPathResult.ANY_TYPE, null);
101
101
  return result.makeString();
@@ -112,11 +112,11 @@ Pathology.XPathResult.prototype.makeString = function() {
112
112
  }
113
113
  return destination;
114
114
  };
115
-
115
+
116
116
  var find = function (root, objectName) {
117
117
  var parts = objectName.split('.'),
118
118
  part;
119
-
119
+
120
120
  while (part = parts.shift()) {
121
121
  root = root[part];
122
122
  if (root === undefined)
@@ -124,31 +124,31 @@ Pathology.XPathResult.prototype.makeString = function() {
124
124
  }
125
125
  return root;
126
126
  };
127
-
127
+
128
128
  var formatError = function (error) {
129
129
  var lines = error.input.split(/\n/g),
130
130
  lineNo = 0,
131
131
  offset = 0;
132
-
132
+
133
133
  while (offset < error.offset + 1) {
134
134
  offset += lines[lineNo].length + 1;
135
135
  lineNo += 1;
136
136
  }
137
137
  var message = 'Line ' + lineNo + ': expected ' + error.expected + '\n',
138
138
  line = lines[lineNo - 1];
139
-
139
+
140
140
  message += line + '\n';
141
141
  offset -= line.length + 1;
142
-
142
+
143
143
  while (offset < error.offset) {
144
144
  message += ' ';
145
145
  offset += 1;
146
146
  }
147
147
  return message + '^';
148
148
  };
149
-
149
+
150
150
  var Grammar = {
151
- __consume__union_expression: function(input) {
151
+ __consume__union_expression: function() {
152
152
  var address0 = null, index0 = this._offset;
153
153
  this._nodeCache["union_expression"] = this._nodeCache["union_expression"] || {};
154
154
  var cached = this._nodeCache["union_expression"][index0];
@@ -287,7 +287,7 @@ Pathology.XPathResult.prototype.makeString = function() {
287
287
  }
288
288
  return this._nodeCache["union_expression"][index0] = address0;
289
289
  },
290
- __consume__location_path: function(input) {
290
+ __consume__location_path: function() {
291
291
  var address0 = null, index0 = this._offset;
292
292
  this._nodeCache["location_path"] = this._nodeCache["location_path"] || {};
293
293
  var cached = this._nodeCache["location_path"][index0];
@@ -350,7 +350,7 @@ Pathology.XPathResult.prototype.makeString = function() {
350
350
  }
351
351
  return this._nodeCache["location_path"][index0] = address0;
352
352
  },
353
- __consume__location_step: function(input) {
353
+ __consume__location_step: function() {
354
354
  var address0 = null, index0 = this._offset;
355
355
  this._nodeCache["location_step"] = this._nodeCache["location_step"] || {};
356
356
  var cached = this._nodeCache["location_step"][index0];
@@ -557,7 +557,7 @@ Pathology.XPathResult.prototype.makeString = function() {
557
557
  }
558
558
  return this._nodeCache["location_step"][index0] = address0;
559
559
  },
560
- __consume__axis: function(input) {
560
+ __consume__axis: function() {
561
561
  var address0 = null, index0 = this._offset;
562
562
  this._nodeCache["axis"] = this._nodeCache["axis"] || {};
563
563
  var cached = this._nodeCache["axis"][index0];
@@ -679,7 +679,7 @@ Pathology.XPathResult.prototype.makeString = function() {
679
679
  }
680
680
  return this._nodeCache["axis"][index0] = address0;
681
681
  },
682
- __consume__axis_shorthand: function(input) {
682
+ __consume__axis_shorthand: function() {
683
683
  var address0 = null, index0 = this._offset;
684
684
  this._nodeCache["axis_shorthand"] = this._nodeCache["axis_shorthand"] || {};
685
685
  var cached = this._nodeCache["axis_shorthand"][index0];
@@ -810,7 +810,7 @@ Pathology.XPathResult.prototype.makeString = function() {
810
810
  }
811
811
  return this._nodeCache["axis_shorthand"][index0] = address0;
812
812
  },
813
- __consume__node_test: function(input) {
813
+ __consume__node_test: function() {
814
814
  var address0 = null, index0 = this._offset;
815
815
  this._nodeCache["node_test"] = this._nodeCache["node_test"] || {};
816
816
  var cached = this._nodeCache["node_test"][index0];
@@ -904,7 +904,7 @@ Pathology.XPathResult.prototype.makeString = function() {
904
904
  }
905
905
  return this._nodeCache["node_test"][index0] = address0;
906
906
  },
907
- __consume__node_condition: function(input) {
907
+ __consume__node_condition: function() {
908
908
  var address0 = null, index0 = this._offset;
909
909
  this._nodeCache["node_condition"] = this._nodeCache["node_condition"] || {};
910
910
  var cached = this._nodeCache["node_condition"][index0];
@@ -1016,7 +1016,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1016
1016
  }
1017
1017
  return this._nodeCache["node_condition"][index0] = address0;
1018
1018
  },
1019
- __consume__node_name: function(input) {
1019
+ __consume__node_name: function() {
1020
1020
  var address0 = null, index0 = this._offset;
1021
1021
  this._nodeCache["node_name"] = this._nodeCache["node_name"] || {};
1022
1022
  var cached = this._nodeCache["node_name"][index0];
@@ -1072,7 +1072,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1072
1072
  }
1073
1073
  return this._nodeCache["node_name"][index0] = address0;
1074
1074
  },
1075
- __consume__subscript: function(input) {
1075
+ __consume__subscript: function() {
1076
1076
  var address0 = null, index0 = this._offset;
1077
1077
  this._nodeCache["subscript"] = this._nodeCache["subscript"] || {};
1078
1078
  var cached = this._nodeCache["subscript"][index0];
@@ -1193,7 +1193,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1193
1193
  }
1194
1194
  return this._nodeCache["subscript"][index0] = address0;
1195
1195
  },
1196
- __consume__node_predicate: function(input) {
1196
+ __consume__node_predicate: function() {
1197
1197
  var address0 = null, index0 = this._offset;
1198
1198
  this._nodeCache["node_predicate"] = this._nodeCache["node_predicate"] || {};
1199
1199
  var cached = this._nodeCache["node_predicate"][index0];
@@ -1316,7 +1316,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1316
1316
  }
1317
1317
  return this._nodeCache["node_predicate"][index0] = address0;
1318
1318
  },
1319
- __consume__expression: function(input) {
1319
+ __consume__expression: function() {
1320
1320
  var address0 = null, index0 = this._offset;
1321
1321
  this._nodeCache["expression"] = this._nodeCache["expression"] || {};
1322
1322
  var cached = this._nodeCache["expression"][index0];
@@ -1347,7 +1347,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1347
1347
  }
1348
1348
  return this._nodeCache["expression"][index0] = address0;
1349
1349
  },
1350
- __consume__or_expression: function(input) {
1350
+ __consume__or_expression: function() {
1351
1351
  var address0 = null, index0 = this._offset;
1352
1352
  this._nodeCache["or_expression"] = this._nodeCache["or_expression"] || {};
1353
1353
  var cached = this._nodeCache["or_expression"][index0];
@@ -1434,7 +1434,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1434
1434
  }
1435
1435
  return this._nodeCache["or_expression"][index0] = address0;
1436
1436
  },
1437
- __consume__and_expression: function(input) {
1437
+ __consume__and_expression: function() {
1438
1438
  var address0 = null, index0 = this._offset;
1439
1439
  this._nodeCache["and_expression"] = this._nodeCache["and_expression"] || {};
1440
1440
  var cached = this._nodeCache["and_expression"][index0];
@@ -1521,7 +1521,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1521
1521
  }
1522
1522
  return this._nodeCache["and_expression"][index0] = address0;
1523
1523
  },
1524
- __consume__comparison: function(input) {
1524
+ __consume__comparison: function() {
1525
1525
  var address0 = null, index0 = this._offset;
1526
1526
  this._nodeCache["comparison"] = this._nodeCache["comparison"] || {};
1527
1527
  var cached = this._nodeCache["comparison"][index0];
@@ -1584,7 +1584,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1584
1584
  }
1585
1585
  return this._nodeCache["comparison"][index0] = address0;
1586
1586
  },
1587
- __consume__comparator: function(input) {
1587
+ __consume__comparator: function() {
1588
1588
  var address0 = null, index0 = this._offset;
1589
1589
  this._nodeCache["comparator"] = this._nodeCache["comparator"] || {};
1590
1590
  var cached = this._nodeCache["comparator"][index0];
@@ -1655,7 +1655,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1655
1655
  }
1656
1656
  return this._nodeCache["comparator"][index0] = address0;
1657
1657
  },
1658
- __consume__atom: function(input) {
1658
+ __consume__atom: function() {
1659
1659
  var address0 = null, index0 = this._offset;
1660
1660
  this._nodeCache["atom"] = this._nodeCache["atom"] || {};
1661
1661
  var cached = this._nodeCache["atom"][index0];
@@ -1808,7 +1808,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1808
1808
  }
1809
1809
  return this._nodeCache["atom"][index0] = address0;
1810
1810
  },
1811
- __consume__value: function(input) {
1811
+ __consume__value: function() {
1812
1812
  var address0 = null, index0 = this._offset;
1813
1813
  this._nodeCache["value"] = this._nodeCache["value"] || {};
1814
1814
  var cached = this._nodeCache["value"][index0];
@@ -1834,7 +1834,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1834
1834
  }
1835
1835
  return this._nodeCache["value"][index0] = address0;
1836
1836
  },
1837
- __consume__function_call: function(input) {
1837
+ __consume__function_call: function() {
1838
1838
  var address0 = null, index0 = this._offset;
1839
1839
  this._nodeCache["function_call"] = this._nodeCache["function_call"] || {};
1840
1840
  var cached = this._nodeCache["function_call"][index0];
@@ -1945,7 +1945,7 @@ Pathology.XPathResult.prototype.makeString = function() {
1945
1945
  }
1946
1946
  return this._nodeCache["function_call"][index0] = address0;
1947
1947
  },
1948
- __consume__function_name: function(input) {
1948
+ __consume__function_name: function() {
1949
1949
  var address0 = null, index0 = this._offset;
1950
1950
  this._nodeCache["function_name"] = this._nodeCache["function_name"] || {};
1951
1951
  var cached = this._nodeCache["function_name"][index0];
@@ -2001,7 +2001,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2001
2001
  }
2002
2002
  return this._nodeCache["function_name"][index0] = address0;
2003
2003
  },
2004
- __consume__function_args: function(input) {
2004
+ __consume__function_args: function() {
2005
2005
  var address0 = null, index0 = this._offset;
2006
2006
  this._nodeCache["function_args"] = this._nodeCache["function_args"] || {};
2007
2007
  var cached = this._nodeCache["function_args"][index0];
@@ -2132,7 +2132,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2132
2132
  }
2133
2133
  return this._nodeCache["function_args"][index0] = address0;
2134
2134
  },
2135
- __consume__integer: function(input) {
2135
+ __consume__integer: function() {
2136
2136
  var address0 = null, index0 = this._offset;
2137
2137
  this._nodeCache["integer"] = this._nodeCache["integer"] || {};
2138
2138
  var cached = this._nodeCache["integer"][index0];
@@ -2243,7 +2243,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2243
2243
  }
2244
2244
  return this._nodeCache["integer"][index0] = address0;
2245
2245
  },
2246
- __consume__string: function(input) {
2246
+ __consume__string: function() {
2247
2247
  var address0 = null, index0 = this._offset;
2248
2248
  this._nodeCache["string"] = this._nodeCache["string"] || {};
2249
2249
  var cached = this._nodeCache["string"][index0];
@@ -2722,7 +2722,7 @@ Pathology.XPathResult.prototype.makeString = function() {
2722
2722
  }
2723
2723
  return this._nodeCache["string"][index0] = address0;
2724
2724
  },
2725
- __consume__space: function(input) {
2725
+ __consume__space: function() {
2726
2726
  var address0 = null, index0 = this._offset;
2727
2727
  this._nodeCache["space"] = this._nodeCache["space"] || {};
2728
2728
  var cached = this._nodeCache["space"][index0];
@@ -2779,13 +2779,13 @@ Pathology.XPathResult.prototype.makeString = function() {
2779
2779
  return this._nodeCache["space"][index0] = address0;
2780
2780
  }
2781
2781
  };
2782
-
2782
+
2783
2783
  var Parser = function(input) {
2784
2784
  this._input = input;
2785
2785
  this._offset = 0;
2786
2786
  this._nodeCache = {};
2787
2787
  };
2788
-
2788
+
2789
2789
  Parser.prototype.parse = function() {
2790
2790
  var result = this.__consume__union_expression();
2791
2791
  if (result && this._offset === this._input.length) {
@@ -2798,14 +2798,14 @@ Pathology.XPathResult.prototype.makeString = function() {
2798
2798
  var error = new Error(message);
2799
2799
  throw error;
2800
2800
  };
2801
-
2801
+
2802
2802
  Parser.parse = function(input) {
2803
2803
  var parser = new Parser(input);
2804
2804
  return parser.parse();
2805
2805
  };
2806
-
2806
+
2807
2807
  extend(Parser.prototype, Grammar);
2808
-
2808
+
2809
2809
  var SyntaxNode = function(textValue, offset, elements, properties) {
2810
2810
  this.textValue = textValue;
2811
2811
  this.offset = offset;
@@ -2813,20 +2813,20 @@ Pathology.XPathResult.prototype.makeString = function() {
2813
2813
  if (!properties) return;
2814
2814
  for (var key in properties) this[key] = properties[key];
2815
2815
  };
2816
-
2816
+
2817
2817
  SyntaxNode.prototype.forEach = function(block, context) {
2818
2818
  for (var i = 0, n = this.elements.length; i < n; i++) {
2819
2819
  block.call(context, this.elements[i], i);
2820
2820
  }
2821
2821
  };
2822
-
2822
+
2823
2823
  Parser.SyntaxNode = SyntaxNode;
2824
-
2824
+
2825
2825
  if (typeof require === "function" && typeof exports === "object") {
2826
2826
  exports.Grammar = Grammar;
2827
2827
  exports.Parser = Parser;
2828
2828
  exports.parse = Parser.parse;
2829
-
2829
+
2830
2830
  if (typeof Pathology !== "undefined") {
2831
2831
  Pathology.XPath = Grammar;
2832
2832
  Pathology.XPathParser = Parser;
@@ -2866,39 +2866,39 @@ Pathology.Axis.prototype.walk = function(context, block, scope) {
2866
2866
  var children = context.childNodes,
2867
2867
  attributes = Pathology.array(context.attributes),
2868
2868
  sibling;
2869
-
2869
+
2870
2870
  if (context.checked)
2871
2871
  attributes.push({ nodeName: 'checked',
2872
2872
  nodeValue: true,
2873
2873
  nodeType: XPathResult.STRING_TYPE
2874
2874
  });
2875
-
2875
+
2876
2876
  if (context.selected)
2877
2877
  attributes.push({ nodeName: 'selected',
2878
2878
  nodeValue: true,
2879
2879
  nodeType: XPathResult.STRING_TYPE
2880
2880
  });
2881
-
2881
+
2882
2882
  switch (this.name) {
2883
2883
  case 'attribute':
2884
2884
  for (var i = 0, n = attributes.length; i < n; i++) {
2885
2885
  block.call(scope, attributes[i]);
2886
2886
  }
2887
2887
  break;
2888
-
2888
+
2889
2889
  case 'child':
2890
2890
  for (var i = 0, n = children.length; i < n; i++) {
2891
2891
  block.call(scope, children[i]);
2892
2892
  }
2893
2893
  break;
2894
-
2894
+
2895
2895
  case 'descendant-or-self':
2896
2896
  block.call(scope, context);
2897
2897
  for (var i = 0, n = children.length; i < n; i++) {
2898
2898
  this.walk(children[i], block, scope);
2899
2899
  }
2900
2900
  break;
2901
-
2901
+
2902
2902
  case 'following-sibling':
2903
2903
  sibling = context.nextSibling;
2904
2904
  while (sibling) {
@@ -2906,11 +2906,11 @@ Pathology.Axis.prototype.walk = function(context, block, scope) {
2906
2906
  sibling = sibling.nextSibling;
2907
2907
  }
2908
2908
  break;
2909
-
2909
+
2910
2910
  case 'parent':
2911
2911
  block.call(scope, context.parentNode);
2912
2912
  break;
2913
-
2913
+
2914
2914
  case 'self':
2915
2915
  block.call(scope, context);
2916
2916
  break;
@@ -2924,12 +2924,12 @@ Pathology.Axis.SHORTHANDS = {
2924
2924
  '/' : 'descendant-or-self',
2925
2925
  '' : 'child'
2926
2926
  };
2927
-
2927
+
2928
2928
  Pathology.Axis.fromAST = function(node) {
2929
2929
  var name = node.axis_name
2930
2930
  ? node.axis_name.textValue
2931
2931
  : node.textValue;
2932
-
2932
+
2933
2933
  return new this(this.SHORTHANDS[name] || name);
2934
2934
  };
2935
2935
 
@@ -2943,7 +2943,7 @@ Pathology.XPathParser.Comparison = {
2943
2943
  viable = false,
2944
2944
  array = (right instanceof Array),
2945
2945
  node;
2946
-
2946
+
2947
2947
  if (left._nodes) {
2948
2948
  for (var i = 0, n = left._nodes.length; i < n; i++) {
2949
2949
  node = left._nodes[i];
@@ -2954,7 +2954,7 @@ Pathology.XPathParser.Comparison = {
2954
2954
  }
2955
2955
  }
2956
2956
  return viable;
2957
-
2957
+
2958
2958
  } else {
2959
2959
  switch (comparator) {
2960
2960
  case '=': return array ? Pathology.indexOf(right, left.nodeValue) >= 0 : left == right;
@@ -2969,7 +2969,7 @@ Pathology.XPathParser.FunctionCall = {
2969
2969
  getArguments: function(context, root) {
2970
2970
  var args = [],
2971
2971
  rest = this.function_args.rest;
2972
-
2972
+
2973
2973
  if (this.function_args.first && this.function_args.first.evaluate) {
2974
2974
  args.push(this.function_args.first.evaluate(context, root));
2975
2975
  }
@@ -2979,14 +2979,14 @@ Pathology.XPathParser.FunctionCall = {
2979
2979
  }
2980
2980
  return args;
2981
2981
  },
2982
-
2982
+
2983
2983
  evaluate: function(context, root) {
2984
2984
  var args = this.getArguments(context, root),
2985
2985
  proc = this.REGISTER[this.function_name.textValue];
2986
-
2986
+
2987
2987
  return proc.apply(context, args);
2988
2988
  },
2989
-
2989
+
2990
2990
  REGISTER: {
2991
2991
  'concat': function() {
2992
2992
  var string = '';
@@ -2994,36 +2994,36 @@ Pathology.XPathParser.FunctionCall = {
2994
2994
  string += arguments[i].makeString ? arguments[i].makeString() : arguments[i];
2995
2995
  return string;
2996
2996
  },
2997
-
2997
+
2998
2998
  'contains': function(haystack, needle) {
2999
2999
  if (!haystack) return false;
3000
3000
  if (haystack.makeString) haystack = haystack.makeString();
3001
-
3001
+
3002
3002
  return haystack.toString().indexOf(needle) >= 0;
3003
3003
  },
3004
-
3004
+
3005
3005
  'normalize-space': function(string) {
3006
3006
  if (string.makeString) string = string.makeString();
3007
-
3007
+
3008
3008
  return string.toString().replace(/^\s*/g, '')
3009
3009
  .replace(/\s*$/g, '')
3010
3010
  .replace(/\s+/g, ' ');
3011
3011
  },
3012
-
3012
+
3013
3013
  'name': function() {
3014
3014
  return this.nodeName.toLowerCase();
3015
3015
  },
3016
-
3016
+
3017
3017
  'not': function(value) {
3018
3018
  if (value && value.atomize) value = value.atomize();
3019
3019
  if (typeof value === 'string') return false;
3020
3020
  return !value;
3021
3021
  },
3022
-
3022
+
3023
3023
  'string': function(value) {
3024
3024
  return value.atomize().innerText;
3025
3025
  },
3026
-
3026
+
3027
3027
  'text': function() {
3028
3028
  return document.evaluate('/text()', this, null, XPathResult.ANY_TYPE, null);
3029
3029
  }
@@ -3037,20 +3037,20 @@ Pathology.XPathParser.LocationPath = {
3037
3037
  for (var i = 0, n = list.length; i < n; i++)
3038
3038
  block.call(scope, list[i]);
3039
3039
  },
3040
-
3040
+
3041
3041
  evaluate: function(context, root, resultType, result) {
3042
3042
  result = result || new Pathology.XPathResult(XPathResult.ANY_TYPE);
3043
3043
  resultType = resultType || XPathResult.ANY_TYPE;
3044
-
3044
+
3045
3045
  var intermediate = new Pathology.XPathResult(resultType),
3046
3046
  startNode = this.head.isRelative() ? context : root,
3047
3047
  steps = [this.head].concat(this.rest.elements),
3048
3048
  step,
3049
3049
  nextStage,
3050
3050
  i, j, n, m;
3051
-
3051
+
3052
3052
  intermediate.push(startNode);
3053
-
3053
+
3054
3054
  for (i = 0, n = steps.length; i < n; i++) {
3055
3055
  step = steps[i];
3056
3056
  nextStage = new Pathology.XPathResult(resultType);
@@ -3059,10 +3059,10 @@ Pathology.XPathParser.LocationPath = {
3059
3059
  }
3060
3060
  intermediate = nextStage;
3061
3061
  }
3062
-
3062
+
3063
3063
  for (i = 0, n = intermediate._nodes.length; i < n; i++)
3064
3064
  result.push(intermediate._nodes[i]);
3065
-
3065
+
3066
3066
  return result;
3067
3067
  }
3068
3068
  };
@@ -3072,12 +3072,12 @@ Pathology.XPathParser.LocationStep = {
3072
3072
  isRelative: function() {
3073
3073
  return this.elements[0].textValue !== '/';
3074
3074
  },
3075
-
3075
+
3076
3076
  evaluate: function(context, root, resultType, result) {
3077
3077
  var axis = this.selector.axis,
3078
3078
  test = this.selector.test,
3079
3079
  levels = [[]];
3080
-
3080
+
3081
3081
  Pathology.Axis.fromAST(axis).walk(context, function(node) {
3082
3082
  if (!test || !test.evaluate) return result.push(node);
3083
3083
  test.evaluate(node, this.predicates, root, resultType, levels, result);
@@ -3090,7 +3090,7 @@ Pathology.XPathParser.NodeTest = {
3090
3090
  evaluate: function(context, predicates, root, resultType, levels, result) {
3091
3091
  var name = this.elements[0].condition_name,
3092
3092
  tagName = tagName = this.elements[0].textValue.toLowerCase();
3093
-
3093
+
3094
3094
  var first = {
3095
3095
  expression: {
3096
3096
  evaluate: function() {
@@ -3111,25 +3111,25 @@ Pathology.XPathParser.NodeTest = {
3111
3111
  },
3112
3112
  subscript: this.subscript
3113
3113
  };
3114
-
3114
+
3115
3115
  predicates = [first].concat(predicates.elements);
3116
3116
  var accepted, predicate;
3117
-
3117
+
3118
3118
  for (var i = 0, n = predicates.length; i < n; i++) {
3119
3119
  levels[i] = levels[i] || [];
3120
3120
  predicate = predicates[i];
3121
-
3121
+
3122
3122
  accepted = Pathology.atomize(predicate.expression, context, root);
3123
3123
  if (typeof accepted === 'string') accepted = true;
3124
3124
  if (!accepted) return;
3125
-
3125
+
3126
3126
  levels[i].push(context);
3127
-
3127
+
3128
3128
  if (predicate.subscript.integer) {
3129
3129
  if (predicate.subscript.integer.evaluate() !== levels[i].length) return;
3130
3130
  }
3131
3131
  }
3132
-
3132
+
3133
3133
  result.push(context);
3134
3134
  }
3135
3135
  };
@@ -3161,13 +3161,13 @@ Pathology.XPathParser.Union = {
3161
3161
  evaluate: function(context, root, resultType, result) {
3162
3162
  result = result || new Pathology.XPathResult(XPathResult.ANY_TYPE);
3163
3163
  resultType = resultType || XPathResult.ANY_TYPE;
3164
-
3164
+
3165
3165
  this.head.evaluate(context, root, resultType, result);
3166
-
3166
+
3167
3167
  var sections = this.rest.elements;
3168
3168
  for (var i = 0, n = sections.length; i < n; i++)
3169
3169
  sections[i].location_path.evaluate(context, root, resultType, result);
3170
-
3170
+
3171
3171
  return result;
3172
3172
  }
3173
3173
  };