r113537 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113536‎ | r113537 | r113538 >
Date:22:45, 9 March 2012
Author:tparscal
Status:deferred
Tags:
Comment:
Cleanup
Modified paths:
  • /trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.js (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/ve/ce/ve.ce.js
@@ -4,29 +4,35 @@
55 * All classes and functions will be attached to this object to keep the global namespace clean.
66 */
77 ve.ce = {
8 -
9 -};
 8+ /**
 9+ * Gets the plain text of a DOM element.
 10+ *
 11+ * @static
 12+ * @method
 13+ * @param {HTMLElement} elem DOM element to get the plan text contents of
 14+ * @returns {String} Plain text contents of DOM element
 15+ */
 16+ 'getDOMText': function( elem ) {
 17+ var nodeType = elem.nodeType,
 18+ ret = '';
1019
11 -ve.ce.getDOMText = function( elem ) {
12 - var nodeType = elem.nodeType,
13 - ret = '';
14 -
15 - if ( nodeType === 1 || nodeType === 9 ) {
16 - // Use textContent || innerText for elements
17 - if ( typeof elem.textContent === 'string' ) {
18 - return elem.textContent;
19 - } else if ( typeof elem.innerText === 'string' ) {
20 - // Replace IE's carriage returns
21 - return elem.innerText.replace( /\r\n/g, '' );
22 - } else {
23 - // Traverse it's children
24 - for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
25 - ret += ve.ce.getDOMText( elem );
 20+ if ( nodeType === 1 || nodeType === 9 ) {
 21+ // Use textContent || innerText for elements
 22+ if ( typeof elem.textContent === 'string' ) {
 23+ return elem.textContent;
 24+ } else if ( typeof elem.innerText === 'string' ) {
 25+ // Replace IE's carriage returns
 26+ return elem.innerText.replace( /\r\n/g, '' );
 27+ } else {
 28+ // Traverse it's children
 29+ for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
 30+ ret += ve.ce.getDOMText( elem );
 31+ }
2632 }
 33+ } else if ( nodeType === 3 || nodeType === 4 ) {
 34+ return elem.nodeValue;
2735 }
28 - } else if ( nodeType === 3 || nodeType === 4 ) {
29 - return elem.nodeValue;
 36+
 37+ return ret;
3038 }
31 -
32 - return ret;
33 -};
\ No newline at end of file
 39+};

Status & tagging log