X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fwalker.js;h=e993f4d3c4574719e694ab5f74ff1cc3b5658f8c;hp=944e12b67bfeb2a1f6fdb2d52c75797b42ef98f6;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hpb=9afde8772159bd3436f1f5b7862960307710ae5a diff --git a/_source/core/dom/walker.js b/_source/core/dom/walker.js index 944e12b..e993f4d 100644 --- a/_source/core/dom/walker.js +++ b/_source/core/dom/walker.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -421,18 +421,34 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }; }; + CKEDITOR.dom.walker.nodeType = function( type, isReject ) + { + return function( node ) + { + return !! ( isReject ^ ( node.type == type ) ); + }; + }; + var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/, - isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( 1 ), - isNotBookmark = CKEDITOR.dom.walker.bookmark( 0, 1 ), - fillerEvaluator = function( element ) + isWhitespaces = CKEDITOR.dom.walker.whitespaces(), + isBookmark = CKEDITOR.dom.walker.bookmark(), + toSkip = function( node ) { - return isNotBookmark( element ) && isNotWhitespaces( element ); + return isBookmark( node ) + || isWhitespaces( node ) + || node.type == CKEDITOR.NODE_ELEMENT + && node.getName() in CKEDITOR.dtd.$inline + && !( node.getName() in CKEDITOR.dtd.$empty ); }; // Check if there's a filler node at the end of an element, and return it. CKEDITOR.dom.element.prototype.getBogus = function() { - var tail = this.getLast( fillerEvaluator ); + // Bogus are not always at the end, e.g.

text

(#7070). + var tail = this; + do { tail = tail.getPreviousSourceNode(); } + while ( toSkip( tail ) ) + if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' ) : tail.getText && tailNbspRegex.test( tail.getText() ) ) ) {