| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | 
							- export const NODE_KEY = '$treeNodeId';
 
- export const markNodeData = function(node, data) {
 
- 	if (!data || data[NODE_KEY]) return;
 
- 	Object.defineProperty(data, NODE_KEY, {
 
- 		value: node.id,
 
- 		enumerable: false,
 
- 		configurable: false,
 
- 		writable: false
 
- 	});
 
- };
 
- export const getNodeKey = function(key, data) {
 
- 	if (!key) return data[NODE_KEY];
 
- 	return data[key];
 
- };
 
- export const objectAssign = function(target) {
 
- 	for (let i = 1, j = arguments.length; i < j; i++) {
 
- 		let source = arguments[i] || {};
 
- 		for (let prop in source) {
 
- 			if (source.hasOwnProperty(prop)) {
 
- 				let value = source[prop];
 
- 				if (value !== undefined) {
 
- 					target[prop] = value;
 
- 				}
 
- 			}
 
- 		}
 
- 	}
 
- 	return target;
 
- };
 
- // TODO: use native Array.find, Array.findIndex when IE support is dropped
 
- export const arrayFindIndex = function(arr, pred) {
 
- 	for (let i = 0; i !== arr.length; ++i) {
 
- 		if (pred(arr[i])) {
 
- 			return i;
 
- 		}
 
- 	}
 
- 	return -1;
 
- };
 
- export const getChildState = function(node) {
 
- 	let all = true;
 
- 	let none = true;
 
- 	let allWithoutDisable = true;
 
- 	for (let i = 0, j = node.length; i < j; i++) {
 
- 		const n = node[i];
 
- 		if (n.checked !== true || n.indeterminate) {
 
- 			all = false;
 
- 			if (!n.disabled) {
 
- 				allWithoutDisable = false;
 
- 			}
 
- 		}
 
- 		if (n.checked !== false || n.indeterminate) {
 
- 			none = false;
 
- 		}
 
- 	}
 
- 	return {
 
- 		all,
 
- 		none,
 
- 		allWithoutDisable,
 
- 		half: !all && !none
 
- 	};
 
- };
 
- export const reInitChecked = function(node) {
 
- 	if (!node || node.childNodesId.length === 0) return;
 
- 	let childNodes = node.getChildNodes(node.childNodesId);
 
- 	const {
 
- 		all,
 
- 		none,
 
- 		half
 
- 	} = getChildState(childNodes);
 
- 	if (all) {
 
- 		node.checked = true;
 
- 		node.indeterminate = false;
 
- 	} else if (half) {
 
- 		node.checked = false;
 
- 		node.indeterminate = true;
 
- 	} else if (none) {
 
- 		node.checked = false;
 
- 		node.indeterminate = false;
 
- 	}
 
- 	let parent = node.getParent(node.parentId);
 
- 	if (!parent || parent.level === 0) return;
 
- 	if (!node.store().checkStrictly) {
 
- 		reInitChecked(parent);
 
- 	}
 
- };
 
- export const getPropertyFromData = function(node, prop) {
 
- 	const props = node.store().props;
 
- 	const data = node.data || {};
 
- 	const config = props[prop];
 
- 	if (typeof config === 'function') {
 
- 		return config(data, node);
 
- 	} else if (typeof config === 'string') {
 
- 		return data[config];
 
- 	} else if (typeof config === 'undefined') {
 
- 		const dataProp = data[prop];
 
- 		return dataProp === undefined ? '' : dataProp;
 
- 	}
 
- };
 
- export const isNull = function(v) {
 
- 	return v === undefined || v === null || v === '';
 
- }
 
 
  |