JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.1
[ckeditor.git] / _source / core / dom / walker.js
index d7934b8..1ef87f5 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
 For licensing, see LICENSE.html or http://ckeditor.com/license\r
 */\r
 \r
@@ -101,7 +101,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                node = null;\r
                                }\r
                                else\r
-                                       node = ( guard ( node ) === false ) ?\r
+                                       node = ( guard ( node, true ) === false ) ?\r
                                                null : node.getPreviousSourceNode( true, type, guard );\r
                        }\r
                        else\r
@@ -115,7 +115,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                node = null;\r
                                }\r
                                else\r
-                                       node = ( guard ( range.startContainer ) === false ) ?\r
+                                       node = ( guard ( range.startContainer, true ) === false ) ?\r
                                                null : range.startContainer.getNextSourceNode( true, type, guard ) ;\r
                        }\r
                }\r
@@ -428,4 +428,24 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                };\r
        };\r
 \r
+       var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/,\r
+               isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ),\r
+               isNotBookmark = CKEDITOR.dom.walker.bookmark( false, true ),\r
+               fillerEvaluator = function( element )\r
+               {\r
+                       return isNotBookmark( element ) && isNotWhitespaces( element );\r
+               };\r
+\r
+       // Check if there's a filler node at the end of an element, and return it.\r
+       CKEDITOR.dom.element.prototype.getBogus = function ()\r
+       {\r
+               var tail = this.getLast( fillerEvaluator );\r
+               if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' )\r
+                               : tail.getText && tailNbspRegex.test( tail.getText() ) ) )\r
+               {\r
+                       return tail;\r
+               }\r
+               return false;\r
+       };\r
+\r
 })();\r