/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
}\r
}\r
\r
+ // Invoke filters sequentially on the array, break the iteration\r
+ // when it doesn't make sense to continue anymore.\r
function callItems( currentEntry )\r
{\r
- var isObject = ( typeof currentEntry == 'object' );\r
+ var isNode = currentEntry.type\r
+ || currentEntry instanceof CKEDITOR.htmlParser.fragment;\r
\r
for ( var i = 0 ; i < this.length ; i++ )\r
{\r
+ // Backup the node info before filtering.\r
+ if ( isNode )\r
+ {\r
+ var orgType = currentEntry.type,\r
+ orgName = currentEntry.name;\r
+ }\r
+\r
var item = this[ i ],\r
ret = item.apply( window, arguments );\r
\r
- if ( typeof ret != 'undefined' )\r
- {\r
- if ( ret === false )\r
- return false;\r
+ if ( ret === false )\r
+ return ret;\r
\r
- if ( isObject && ret != currentEntry )\r
+ // We're filtering node (element/fragment).\r
+ if ( isNode )\r
+ {\r
+ // No further filtering if it's not anymore\r
+ // fitable for the subsequent filters.\r
+ if ( ret && ( ret.name != orgName\r
+ || ret.type != orgType ) )\r
+ {\r
+ return ret;\r
+ }\r
+ }\r
+ // Filtering value (nodeName/textValue/attrValue).\r
+ else\r
+ {\r
+ // No further filtering if it's not\r
+ // any more values.\r
+ if ( typeof ret != 'string' )\r
return ret;\r
}\r
+\r
+ ret != undefined && ( currentEntry = ret );\r
}\r
\r
- return null;\r
+ return currentEntry;\r
}\r
})();\r
\r