Index: /CKEditor/trunk/_source/core/dom/node.js =================================================================== --- /CKEditor/trunk/_source/core/dom/node.js (revision 3535) +++ /CKEditor/trunk/_source/core/dom/node.js (revision 3536) @@ -272,7 +272,4 @@ getNextSourceNode : function( startFromSibling, nodeType, guard ) { - var node = ( !startFromSibling && this.getFirst && this.getFirst() ) || this.getNext(), - parent; - // If "guard" is a node, transform it in a function. if ( guard && !guard.call ) @@ -283,4 +280,16 @@ return !node.equals( guardNode ); }; + } + + var node = ( !startFromSibling && this.getFirst && this.getFirst() ), + parent; + + // Guarding when we're skipping the current element( no children or 'startFromSibling' ). + // send the 'moving out' signal even we don't actually dive into. + if ( !node ) + { + if ( this.type == CKEDITOR.NODE_ELEMENT && guard && guard( this, true ) === false ) + return null; + node = this.getNext(); } @@ -309,7 +318,4 @@ getPreviousSourceNode : function( startFromSibling, nodeType, guard ) { - var node = ( !startFromSibling && this.getLast && this.getLast() ) || this.getPrevious(), - parent; - if ( guard && !guard.call ) { @@ -319,4 +325,16 @@ return !node.equals( guardNode ); }; + } + + var node = ( !startFromSibling && this.getLast && this.getLast() ), + parent; + + // Guarding when we're skipping the current element( no children or 'startFromSibling' ). + // send the 'moving out' signal even we don't actually dive into. + if ( !node ) + { + if ( this.type == CKEDITOR.NODE_ELEMENT && guard && guard( this, true ) === false ) + return null; + node = this.getPrevious(); } Index: /CKEditor/trunk/_source/tests/core/dom/walker.html =================================================================== --- /CKEditor/trunk/_source/tests/core/dom/walker.html (revision 3535) +++ /CKEditor/trunk/_source/tests/core/dom/walker.html (revision 3536) @@ -302,14 +302,41 @@ assertNodesList( [ '
', ' test', '', '', 'simple', 'a ', 'This is ' ], nodes );
},
-
+ /**
+ * Test walker stop at empty endContainer.
+ */
+ test_stopGuard : function()
+ {
+ var node = doc.getById( 'playground' );
+ node.setHtml( 'afterEnd' );
+ var endContainer = node.getFirst();
+ var range = new CKEDITOR.dom.range( doc );
+ range.selectNodeContents( node );
+ range.setEndAt( endContainer, CKEDITOR.POSITION_AFTER_START );
+
+ var walker = new CKEDITOR.dom.walker( range );
+ var nodes = [];
+
+ walker.evaluator = function( node )
+ {
+ nodes.push( node );
+ return true;
+ };
+
+ while ( ( node = walker.next() ) )
+ { /*jsl:pass*/ }
+
+ assertNodesList( [ '' ], nodes );
+
+ },
name : document.title
};
})() );
+//window.onload = tc.test_stopGuard;
//]]>
-