if ( !this._.lastNode )\r
{\r
range = this.range.clone();\r
+\r
+ // Shrink the range to exclude harmful "noises" (#4087, #4450, #5435).\r
+ range.shrink( CKEDITOR.NODE_ELEMENT, true );\r
+\r
range.enlarge( this.forceBrBreak || !this.enlargeBr ?\r
CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS : CKEDITOR.ENLARGE_BLOCK_CONTENTS );\r
\r
\r
// We have found a block boundary. Let's close the range and move out of the\r
// loop.\r
- if ( ( closeRange || isLast ) && range )\r
- {\r
- var boundaryNodes = range.getBoundaryNodes(),\r
- startPath = new CKEDITOR.dom.elementPath( range.startContainer );\r
-\r
- // Drop the range if it only contains bookmark nodes, and is\r
- // not because of the original collapsed range. (#4087,#4450)\r
- if ( boundaryNodes.startNode.getParent().equals( startPath.blockLimit )\r
- && isBookmark( boundaryNodes.startNode ) && isBookmark( boundaryNodes.endNode ) )\r
- {\r
- range = null;\r
- this._.nextNode = null;\r
- }\r
- else\r
+ if ( isLast || ( closeRange && range ) )\r
break;\r
- }\r
-\r
- if ( isLast )\r
- break;\r
-\r
}\r
\r
// Now, based on the processed range, look for (or create) the block to be returned.\r
return null;\r
}\r
\r
- startPath = new CKEDITOR.dom.elementPath( range.startContainer );\r
+ var startPath = new CKEDITOR.dom.elementPath( range.startContainer );\r
var startBlockLimit = startPath.blockLimit,\r
checkLimits = { div : 1, th : 1, td : 1 };\r
block = startPath.block;\r