X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser%2Ffilter.js;h=5d16292ce7b39bf239403abe83d04837f33a2083;hp=1699eb265a93ff001f4e048057076dadae2a6ffc;hb=8665a7c6c60586526e32e8941fe2896739b6ebfb;hpb=e7789c1ad838194d45eeee6ac2eb6e55f5cf35a1 diff --git a/_source/core/htmlparser/filter.js b/_source/core/htmlparser/filter.js index 1699eb2..5d16292 100644 --- a/_source/core/htmlparser/filter.js +++ b/_source/core/htmlparser/filter.js @@ -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; } })();