X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fhtmlparser%2Ffilter.js;h=a1f16e2a9e36a8806ed7758dce9ff2979c44543f;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hp=1699eb265a93ff001f4e048057076dadae2a6ffc;hpb=c6e377a02b54abc07129d72b632763c727476a15;p=ckeditor.git diff --git a/_source/core/htmlparser/filter.js b/_source/core/htmlparser/filter.js index 1699eb2..a1f16e2 100644 --- a/_source/core/htmlparser/filter.js +++ b/_source/core/htmlparser/filter.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -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; } })();