X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser%2Ffilter.js;h=cbe4bede4ded37df51d6a83c4ec54fd1aa36e5ea;hp=6001e681a538f243703c17b2bdc83e94ae588a1a;hb=941b0a9ba4e673e292510d80a5a86806994b8ea6;hpb=7cd80714081a8ffdf4a1a8d2c72f120ed5ef3d6d diff --git a/_source/core/htmlparser/filter.js b/_source/core/htmlparser/filter.js index 6001e68..cbe4bed 100644 --- a/_source/core/htmlparser/filter.js +++ b/_source/core/htmlparser/filter.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -45,6 +45,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // Add the comment. this._.comment = transformNamedItem( this._.comment, rules.comment, priority ) || this._.comment; + + // Add root fragment. + this._.root = transformNamedItem( this._.root, rules.root, priority ) || this._.root; }, onElementName : function( name ) @@ -63,10 +66,16 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return textFilter ? textFilter.filter( text ) : text; }, - onComment : function( commentText ) + onComment : function( commentText, comment ) { var textFilter = this._.comment; - return textFilter ? textFilter.filter( commentText ) : commentText; + return textFilter ? textFilter.filter( commentText, comment ) : commentText; + }, + + onFragment : function( element ) + { + var rootFilter = this._.root; + return rootFilter ? rootFilter.filter( element ) : element; }, onElement : function( element ) @@ -74,10 +83,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // We must apply filters set to the specific element name as // well as those set to the generic $ name. So, add both to an // array and process them in a small loop. - var filters = [ this._.elements[ element.name ], this._.elements.$ ], + var filters = [ this._.elements[ '^' ], this._.elements[ element.name ], this._.elements.$ ], filter, ret; - for ( var i = 0 ; i < 2 ; i++ ) + for ( var i = 0 ; i < 3 ; i++ ) { filter = filters[ i ]; if ( filter ) @@ -88,13 +97,27 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return null; if ( ret && ret != element ) - return this.onElement( ret ); + return this.onNode( ret ); + + // The non-root element has been dismissed by one of the filters. + if ( element.parent && !element.name ) + break; } } return element; }, + onNode : function( node ) + { + var type = node.type; + + return type == CKEDITOR.NODE_ELEMENT ? this.onElement( node ) : + type == CKEDITOR.NODE_TEXT ? new CKEDITOR.htmlParser.text( this.onText( node.value ) ) : + type == CKEDITOR.NODE_COMMENT ? new CKEDITOR.htmlParser.comment( this.onComment( node.value ) ): + null; + }, + onAttribute : function( element, name, value ) { var filter = this._.attributes[ name ]; @@ -144,8 +167,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license for ( j = itemsLength - 1 ; j >= 0 ; j-- ) { var item = items[ j ]; - item.pri = priority; - list.splice( i, 0, item ); + if ( item ) + { + item.pri = priority; + list.splice( i, 0, item ); + } } } }