Fix ve.ce.getDomText to work with <br/> tags by making it skip not contenteditable=false but all leaf nodes.

Change-Id: I9e728e091a3021840dac07e9601fc764e7750c49
This commit is contained in:
Inez Korczynski 2012-08-22 11:08:11 -07:00
parent 43e8403273
commit 9920fb0725

View file

@ -24,7 +24,7 @@ ve.ce = {
ve.ce.whitespacePattern = /[\u0020\u00A0]/g;
/**
* Gets the plain text of a DOM element.
* Gets the plain text of a DOM element (that is a node canContainContent === true)
*
* In the returned string only the contents of text nodes are included, and the contents of
* non-editable elements are excluded (but replaced with the appropriate number of characters
@ -39,12 +39,14 @@ ve.ce.getDomText = function ( element ) {
var func = function ( element ) {
var nodeType = element.nodeType,
text = '',
numChars;
numChars,
$element = $( element );
if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
if ( element.contentEditable === 'false' ) {
// For non-editable nodes, don't return the content, but return
if ( $element.hasClass( 've-ce-leafNode' ) ) {
// For leaf nodes, don't return the content, but return
// the right amount of characters so the offsets match up
numChars = $( element ).data( 'node' ).getOuterLength();
numChars = $element.data( 'node' ).getOuterLength();
return new Array( numChars + 1 ).join( '\u2603' );
} else {
// Traverse its children