/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
\r
while ( ( range = iterator.getNextRange() ) )\r
{\r
- if ( range.collapsed )\r
- continue;\r
-\r
- range.enlarge( CKEDITOR.ENLARGE_ELEMENT );\r
+ if ( ! range.collapsed )\r
+ range.enlarge( CKEDITOR.ENLARGE_ELEMENT );\r
\r
// Bookmark the range so we can re-select it after processing.\r
- var bookmark = range.createBookmark();\r
-\r
- // The style will be applied within the bookmark boundaries.\r
- var startNode = bookmark.startNode,\r
- endNode = bookmark.endNode;\r
+ var bookmark = range.createBookmark(),\r
+ // The style will be applied within the bookmark boundaries.\r
+ startNode = bookmark.startNode,\r
+ endNode = bookmark.endNode,\r
+ currentNode;\r
\r
// We need to check the selection boundaries (bookmark spans) to break\r
// the code in a way that we can properly remove partially selected nodes.\r
};\r
\r
breakParent( startNode );\r
- breakParent( endNode );\r
+ if ( endNode )\r
+ {\r
+ breakParent( endNode );\r
\r
- // Navigate through all nodes between the bookmarks.\r
- var currentNode = startNode.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT );\r
+ // Navigate through all nodes between the bookmarks.\r
+ currentNode = startNode.getNextSourceNode( true, CKEDITOR.NODE_ELEMENT );\r
\r
- while ( currentNode )\r
- {\r
- // If we have reached the end of the selection, stop looping.\r
- if ( currentNode.equals( endNode ) )\r
- break;\r
-\r
- // Cache the next node to be processed. Do it now, because\r
- // currentNode may be removed.\r
- var nextNode = currentNode.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT );\r
-\r
- // This node must not be a fake element.\r
- if ( !( currentNode.getName() == 'img'\r
- && currentNode.getAttribute( '_cke_realelement' ) )\r
- && filter( editor, currentNode ) )\r
+ while ( currentNode )\r
{\r
- // Remove elements nodes that match with this style rules.\r
- if ( tagsRegex.test( currentNode.getName() ) )\r
- currentNode.remove( 1 );\r
- else\r
+ // If we have reached the end of the selection, stop looping.\r
+ if ( currentNode.equals( endNode ) )\r
+ break;\r
+\r
+ // Cache the next node to be processed. Do it now, because\r
+ // currentNode may be removed.\r
+ var nextNode = currentNode.getNextSourceNode( false, CKEDITOR.NODE_ELEMENT );\r
+\r
+ // This node must not be a fake element.\r
+ if ( !( currentNode.getName() == 'img'\r
+ && currentNode.data( 'cke-realelement' ) )\r
+ && filter( editor, currentNode ) )\r
{\r
- currentNode.removeAttributes( removeAttributes );\r
- editor.fire( 'removeFormatCleanup', currentNode );\r
+ // Remove elements nodes that match with this style rules.\r
+ if ( tagsRegex.test( currentNode.getName() ) )\r
+ currentNode.remove( 1 );\r
+ else\r
+ {\r
+ currentNode.removeAttributes( removeAttributes );\r
+ editor.fire( 'removeFormatCleanup', currentNode );\r
+ }\r
}\r
- }\r
\r
- currentNode = nextNode;\r
+ currentNode = nextNode;\r
+ }\r
}\r
\r
range.moveToBookmark( bookmark );\r
\r
/**\r
* Fired after an element was cleaned by the removeFormat plugin.\r
- * @name CKEDITOR#removeFormatCleanup\r
+ * @name CKEDITOR.editor#removeFormatCleanup\r
* @event\r
* @param {Object} data.element The element that was cleaned up.\r
*/\r