X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fwalker.js;h=1ef87f576869df20dd2fb2881d0d1fec272e7320;hb=refs%2Ftags%2Fv3.3.1;hp=d7934b8113ee305fe65420eb22cc8ba3c2741572;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d;p=ckeditor.git diff --git a/_source/core/dom/walker.js b/_source/core/dom/walker.js index d7934b8..1ef87f5 100644 --- a/_source/core/dom/walker.js +++ b/_source/core/dom/walker.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -101,7 +101,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license node = null; } else - node = ( guard ( node ) === false ) ? + node = ( guard ( node, true ) === false ) ? null : node.getPreviousSourceNode( true, type, guard ); } else @@ -115,7 +115,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license node = null; } else - node = ( guard ( range.startContainer ) === false ) ? + node = ( guard ( range.startContainer, true ) === false ) ? null : range.startContainer.getNextSourceNode( true, type, guard ) ; } } @@ -428,4 +428,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }; }; + var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/, + isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ), + isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true ), + fillerEvaluator = function( element ) + { + return isNotBookmark( element ) && isNotWhitespaces( element ); + }; + + // 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 ); + if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' ) + : tail.getText && tailNbspRegex.test( tail.getText() ) ) ) + { + return tail; + } + return false; + }; + })();