Ticket #5617: 5617_2.patch

File 5617_2.patch, 1.6 KB (added by Garry Yao, 14 years ago)
  • _source/core/htmlparser/filter.js

     
    227227                }
    228228        }
    229229
     230        // Invoke filters sequentially on the array, break the iteration
     231        // when it doesn't make sense to continue anymore.
    230232        function callItems( currentEntry )
    231233        {
    232                 var isObject = ( typeof currentEntry == 'object' );
     234                var isNode = currentEntry.type
     235                        || currentEntry instanceof CKEDITOR.htmlParser.fragment;
    233236
    234237                for ( var i = 0 ; i < this.length ; i++ )
    235238                {
     239                        // Backup the node info before filtering.
     240                        if ( isNode )
     241                        {
     242                                var orgType = currentEntry.type,
     243                                                orgName = currentEntry.name;
     244                        }
     245
    236246                        var item = this[ i ],
    237247                                ret = item.apply( window, arguments );
    238248
    239                         if ( typeof ret != 'undefined' )
    240                         {
    241                                 if ( ret === false )
    242                                         return false;
     249                        if ( ret === false )
     250                                return ret;
    243251
    244                                 if ( isObject && ret != currentEntry )
     252                        // We're filtering node (element/fragment).
     253                        if ( isNode )
     254                        {
     255                                // No further filtering if it's not anymore
     256                                // fitable for the subsequent filters.
     257                                if ( !ret || currentEntry.name != orgName
     258                                        || currentEntry.type != orgType )
     259                                {
    245260                                        return ret;
    246                         }
    247                 }
     261                                }
     262                        }
     263                        // Filtering value (nodeName/textValue/attrValue).
     264                        else
     265                        {
     266                                // No further filtering if it's not
     267                                // any more values.
     268                                if ( typeof ret != 'string' )
     269                                        return ret;
     270                        }
    248271
    249                 return null;
    250         }
     272                        currentEntry = ret;
     273                }
     274
     275                return currentEntry;
     276        }
    251277})();
    252278
    253279// "entities" plugin
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy