From 7adcb81e4f83f98c468889aaa5a85558ba88c770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 25 Jan 2016 17:45:33 +0100 Subject: Initial commit --- sources/core/dom/nodelist.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sources/core/dom/nodelist.js (limited to 'sources/core/dom/nodelist.js') diff --git a/sources/core/dom/nodelist.js b/sources/core/dom/nodelist.js new file mode 100644 index 00000000..0bbe3ee6 --- /dev/null +++ b/sources/core/dom/nodelist.js @@ -0,0 +1,43 @@ +/** + * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.md or http://ckeditor.com/license + */ + +/** + * Represents a list of {@link CKEDITOR.dom.node} objects. + * It's a wrapper for native nodes list. + * + * var nodeList = CKEDITOR.document.getBody().getChildren(); + * alert( nodeList.count() ); // number [0;N] + * + * @class + * @constructor Creates a document class instance. + * @param {Object} nativeList + */ +CKEDITOR.dom.nodeList = function( nativeList ) { + this.$ = nativeList; +}; + +CKEDITOR.dom.nodeList.prototype = { + /** + * Get count of nodes in this list. + * + * @returns {Number} + */ + count: function() { + return this.$.length; + }, + + /** + * Get node from the list. + * + * @returns {CKEDITOR.dom.node} + */ + getItem: function( index ) { + if ( index < 0 || index >= this.$.length ) + return null; + + var $node = this.$[ index ]; + return $node ? new CKEDITOR.dom.node( $node ) : null; + } +}; -- cgit v1.2.3