mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Cleanup
This commit is contained in:
parent
4bc7dbbe5e
commit
ce824d6299
Notes:
Trevor Parscal
2012-03-09 22:45:22 +00:00
|
@ -4,29 +4,35 @@
|
|||
* All classes and functions will be attached to this object to keep the global namespace clean.
|
||||
*/
|
||||
ve.ce = {
|
||||
/**
|
||||
* Gets the plain text of a DOM element.
|
||||
*
|
||||
* @static
|
||||
* @method
|
||||
* @param {HTMLElement} elem DOM element to get the plan text contents of
|
||||
* @returns {String} Plain text contents of DOM element
|
||||
*/
|
||||
'getDOMText': function( elem ) {
|
||||
var nodeType = elem.nodeType,
|
||||
ret = '';
|
||||
|
||||
};
|
||||
|
||||
ve.ce.getDOMText = function( elem ) {
|
||||
var nodeType = elem.nodeType,
|
||||
ret = '';
|
||||
|
||||
if ( nodeType === 1 || nodeType === 9 ) {
|
||||
// Use textContent || innerText for elements
|
||||
if ( typeof elem.textContent === 'string' ) {
|
||||
return elem.textContent;
|
||||
} else if ( typeof elem.innerText === 'string' ) {
|
||||
// Replace IE's carriage returns
|
||||
return elem.innerText.replace( /\r\n/g, '' );
|
||||
} else {
|
||||
// Traverse it's children
|
||||
for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
|
||||
ret += ve.ce.getDOMText( elem );
|
||||
if ( nodeType === 1 || nodeType === 9 ) {
|
||||
// Use textContent || innerText for elements
|
||||
if ( typeof elem.textContent === 'string' ) {
|
||||
return elem.textContent;
|
||||
} else if ( typeof elem.innerText === 'string' ) {
|
||||
// Replace IE's carriage returns
|
||||
return elem.innerText.replace( /\r\n/g, '' );
|
||||
} else {
|
||||
// Traverse it's children
|
||||
for ( elem = elem.firstChild; elem; elem = elem.nextSibling) {
|
||||
ret += ve.ce.getDOMText( elem );
|
||||
}
|
||||
}
|
||||
} else if ( nodeType === 3 || nodeType === 4 ) {
|
||||
return elem.nodeValue;
|
||||
}
|
||||
} else if ( nodeType === 3 || nodeType === 4 ) {
|
||||
return elem.nodeValue;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue