Skip to content

Commit

Permalink
Merge branch 't/10822' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Oct 24, 2013
2 parents 29ae680 + c005327 commit b6d7b38
Show file tree
Hide file tree
Showing 9 changed files with 618 additions and 245 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -5,6 +5,7 @@ CKEditor 4 Changelog

New Features:

* [#10822](http://dev.ckeditor.com/ticket/10822): Added styles system integration with non-editable elements (for example widgets) and their nested editables. Styles cannot change non-editable content and are applied in nested editable only if allowed by its type and content filter.
* [#10855](http://dev.ckeditor.com/ticket/10855): Change extension of emotes in BBCode sample from GIF to PNG.
* [#11002](http://dev.ckeditor.com/ticket/11002): Added option to disable widgets drag and drop support.
* [#10430](http://dev.ckeditor.com/ticket/10430): Resolve dependence of image plugin if forms plugin.
Expand Down
46 changes: 46 additions & 0 deletions core/dom/element.js
Expand Up @@ -1868,6 +1868,52 @@ CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype, {
removeTmpId();

return found ? new CKEDITOR.dom.element( found ) : null;
},

/**
* Traverse the DOM of this element (inclusive), executing a callback for
* each node.
*
* var element = CKEDITOR.dom.element.createFromHtml( '<div><p>foo<b>bar</b>bom</p></div>' );
* element.forEach( function( node ) {
* console.log( node );
* } );
* // Will log:
* // 1. <div> element,
* // 2. <p> element,
* // 3. "foo" text node,
* // 4. <b> element,
* // 5. "bar" text node,
* // 6. "bom" text node.
*
* @since 4.3
* @param {Function} callback Function to be executed on every node.
* If `callback` returns `false` descendants of the node will be ignored.
* @param {CKEDITOR.htmlParser.node} callback.node Node passed as argument.
* @param {Number} [type] If specified `callback` will be executed only on
* nodes of this type.
* @param {Boolean} [skipRoot] Don't execute `callback` on this element.
*/
forEach: function( callback, type, skipRoot ) {
if ( !skipRoot && ( !type || this.type == type ) )
var ret = callback( this );

// Do not filter children if callback returned false.
if ( ret === false )
return;

var children = this.getChildren(),
node,
i = 0;

// We do not cache the size, because the live list of nodes may be changed by the callback.
for ( ; i < children.count(); i++ ) {
node = children.getItem( i );
if ( node.type == CKEDITOR.NODE_ELEMENT )
node.forEach( callback, type );
else if ( !type || node.type == type )
callback( node );
}
}
});

Expand Down

0 comments on commit b6d7b38

Please sign in to comment.