Sha256: ca3e97358b644a1590d52042d36ef273a72a266bfd8b503d3a19643d1decd4f3

Contents?: true

Size: 959 Bytes

Versions: 3

Compression:

Stored size: 959 Bytes

Contents

/**
 * NodePath.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2015 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */

/**
 * Handles paths of nodes within an element.
 *
 * @private
 * @class tinymce.dom.NodePath
 */
define("tinymce/dom/NodePath", [
	"tinymce/dom/DOMUtils"
], function(DOMUtils) {
	function create(rootNode, targetNode, normalized) {
		var path = [];

		for (; targetNode && targetNode != rootNode; targetNode = targetNode.parentNode) {
			path.push(DOMUtils.nodeIndex(targetNode, normalized));
		}

		return path;
	}

	function resolve(rootNode, path) {
		var i, node, children;

		for (node = rootNode, i = path.length - 1; i >= 0; i--) {
			children = node.childNodes;

			if (path[i] > children.length - 1) {
				return null;
			}

			node = children[path[i]];
		}

		return node;
	}

	return {
		create: create,
		resolve: resolve
	};
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spiderfw-1.0.1 apps/core/components/public/js/tinymce/classes/dom/NodePath.js
spiderfw-1.0.0 apps/core/components/public/js/tinymce/classes/dom/NodePath.js
spiderfw-0.6.39 apps/core/components/public/js/tinymce/classes/dom/NodePath.js