X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fdom%2Fwalker.js;h=e993f4d3c4574719e694ab5f74ff1cc3b5658f8c;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=126f3f205819972d2dfc656dcc7a83530d41293c;hpb=614511639979907ceb0da3614122a4d8eb963ad4;p=ckeditor.git diff --git a/_source/core/dom/walker.js b/_source/core/dom/walker.js index 126f3f2..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 */ @@ -373,7 +373,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { return ( node && node.getName && node.getName() == 'span' - && node.hasAttribute( '_cke_bookmark' ) ); + && node.data( 'cke-bookmark' ) ); } return function( node ) @@ -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() ) ) ) {