Skip to content

Commit

Permalink
feature #22917 [VarDumper] Cycle prev/next searching in HTML dumps (r…
Browse files Browse the repository at this point in the history
…o0NL)

This PR was submitted for the 3.3 branch but it was merged into the 3.4 branch instead (closes #22917).

Discussion
----------

[VarDumper] Cycle prev/next searching in HTML dumps

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

This cycles the prev/next searching in html dumps and mimics (at least) chrome's search bar. It's truly convenient, hence 3.3

cc @ogizanagi

Commits
-------

73f24e8 search case insensitive
0821c5a [VarDumper] Cyclic searching dumps
  • Loading branch information
fabpot committed Jun 9, 2017
2 parents bdd888f + 73f24e8 commit ea3ed4c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,15 +425,15 @@ function xpathString(str) {
if (this.isEmpty()) {
return this.current();
}
this.idx = this.idx < (this.nodes.length - 1) ? this.idx + 1 : this.idx;
this.idx = this.idx < (this.nodes.length - 1) ? this.idx + 1 : 0;
return this.current();
},
previous: function () {
if (this.isEmpty()) {
return this.current();
}
this.idx = this.idx > 0 ? this.idx - 1 : this.idx;
this.idx = this.idx > 0 ? this.idx - 1 : (this.nodes.length - 1);
return this.current();
},
Expand Down Expand Up @@ -507,7 +507,7 @@ function showCurrent(state)
return;
}
var xpathResult = doc.evaluate('//pre[@id="' + root.id + '"]//span[@class="sf-dump-str" or @class="sf-dump-key" or @class="sf-dump-public" or @class="sf-dump-protected" or @class="sf-dump-private"][contains(child::text(), ' + xpathString(searchQuery) + ')]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
var xpathResult = doc.evaluate('//pre[@id="' + root.id + '"]//span[@class="sf-dump-str" or @class="sf-dump-key" or @class="sf-dump-public" or @class="sf-dump-protected" or @class="sf-dump-private"][contains(translate(child::text(), ' + xpathString(searchQuery.toUpperCase()) + ', ' + xpathString(searchQuery.toLowerCase()) + '), ' + xpathString(searchQuery.toLowerCase()) + ')]', document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
while (node = xpathResult.iterateNext()) state.nodes.push(node);
Expand Down

0 comments on commit ea3ed4c

Please sign in to comment.