Index: /CKEditor/trunk/_source/core/dom/node.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/node.js	(revision 3354)
+++ /CKEditor/trunk/_source/core/dom/node.js	(revision 3355)
@@ -315,5 +315,5 @@
 
 			if ( nodeType && nodeType != node.type )
-				return arguments.callee.call( { $ : node }, false, nodeType );
+				return node.getNextSourceNode( false, nodeType, guard );
 
 			return node;
@@ -349,5 +349,5 @@
 
 			if ( nodeType && node.type != nodeType )
-				return arguments.callee.call( { $ : node }, false, nodeType );
+				return node.getPreviousSourceNode( false, nodeType, guard );
 
 			return node;
Index: /CKEditor/trunk/_source/plugins/selection/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/selection/plugin.js	(revision 3354)
+++ /CKEditor/trunk/_source/plugins/selection/plugin.js	(revision 3355)
@@ -260,5 +260,6 @@
 	CKEDITOR.dom.document.prototype.getSelection = function()
 	{
-		return new CKEDITOR.dom.selection( this );
+		var sel = new CKEDITOR.dom.selection( this );
+		return ( !sel || sel.isInvalid ) ? null : sel;
 	};
 
@@ -320,9 +321,7 @@
 				|| ( range.parentElement && range.parentElement().ownerDocument != this.document.$ ) )
 			{
-				return null;
+				this.isInvalid = true;
 			}
 		}
-		
-		return this;
 	};
 
