X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser%2Ffilter.js;h=5d16292ce7b39bf239403abe83d04837f33a2083;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hp=cbe4bede4ded37df51d6a83c4ec54fd1aa36e5ea;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/core/htmlparser/filter.js b/_source/core/htmlparser/filter.js index cbe4bed..5d16292 100644 --- a/_source/core/htmlparser/filter.js +++ b/_source/core/htmlparser/filter.js @@ -150,7 +150,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function addItemsToList( list, items, priority ) { - if( typeof items == 'function' ) + if ( typeof items == 'function' ) items = [ items ]; var i, j, @@ -227,26 +227,52 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } } + // Invoke filters sequentially on the array, break the iteration + // when it doesn't make sense to continue anymore. function callItems( currentEntry ) { - var isObject = ( typeof currentEntry == 'object' ); + var isNode = currentEntry.type + || currentEntry instanceof CKEDITOR.htmlParser.fragment; for ( var i = 0 ; i < this.length ; i++ ) { + // Backup the node info before filtering. + if ( isNode ) + { + var orgType = currentEntry.type, + orgName = currentEntry.name; + } + var item = this[ i ], ret = item.apply( window, arguments ); - if ( typeof ret != 'undefined' ) - { - if ( ret === false ) - return false; + if ( ret === false ) + return ret; - if ( isObject && ret != currentEntry ) + // We're filtering node (element/fragment). + if ( isNode ) + { + // No further filtering if it's not anymore + // fitable for the subsequent filters. + if ( ret && ( ret.name != orgName + || ret.type != orgType ) ) + { + return ret; + } + } + // Filtering value (nodeName/textValue/attrValue). + else + { + // No further filtering if it's not + // any more values. + if ( typeof ret != 'string' ) return ret; } + + ret != undefined && ( currentEntry = ret ); } - return null; + return currentEntry; } })();