Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 | 574 |
| 575 /** | 575 /** |
| 576 * @param {...!Node} var_args | 576 * @param {...!Node} var_args |
| 577 */ | 577 */ |
| 578 Node.prototype.appendChildren = function(var_args) { | 578 Node.prototype.appendChildren = function(var_args) { |
| 579 for (var i = 0, n = arguments.length; i < n; ++i) | 579 for (var i = 0, n = arguments.length; i < n; ++i) |
| 580 this.appendChild(arguments[i]); | 580 this.appendChild(arguments[i]); |
| 581 }; | 581 }; |
| 582 | 582 |
| 583 /** | 583 /** |
| 584 * @param {function(!Node):string=} transform | |
| 584 * @return {string} | 585 * @return {string} |
| 585 */ | 586 */ |
| 586 Node.prototype.deepTextContent = function() { | 587 Node.prototype.deepTextContent = function(transform) { |
|
dgozman
2016/12/19 18:38:01
Instead of adding transform here, let's copy this
luoe
2016/12/19 19:44:39
Done.
| |
| 587 return this.childTextNodes() | 588 return this.childTextNodes() |
| 588 .map(function(node) { | 589 .map(function(node) { |
| 590 if (typeof transform === 'function') | |
| 591 return transform(node); | |
| 589 return node.textContent; | 592 return node.textContent; |
| 590 }) | 593 }) |
| 591 .join(''); | 594 .join(''); |
| 592 }; | 595 }; |
| 593 | 596 |
| 594 /** | 597 /** |
| 595 * @return {!Array.<!Node>} | 598 * @return {!Array.<!Node>} |
| 596 */ | 599 */ |
| 597 Node.prototype.childTextNodes = function() { | 600 Node.prototype.childTextNodes = function() { |
| 598 var node = this.traverseNextTextNode(this); | 601 var node = this.traverseNextTextNode(this); |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 function windowLoaded() { | 821 function windowLoaded() { |
| 819 window.removeEventListener('DOMContentLoaded', windowLoaded, false); | 822 window.removeEventListener('DOMContentLoaded', windowLoaded, false); |
| 820 callback(); | 823 callback(); |
| 821 } | 824 } |
| 822 | 825 |
| 823 if (document.readyState === 'complete' || document.readyState === 'interactive ') | 826 if (document.readyState === 'complete' || document.readyState === 'interactive ') |
| 824 callback(); | 827 callback(); |
| 825 else | 828 else |
| 826 window.addEventListener('DOMContentLoaded', windowLoaded, false); | 829 window.addEventListener('DOMContentLoaded', windowLoaded, false); |
| 827 } | 830 } |
| OLD | NEW |