Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
warmhug committed Mar 7, 2016
1 parent 82aba68 commit c1fce85
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Demo = React.createClass({
<h2>single select</h2>
<TreeSelect style={{width: 300}}
dropdownStyle={{maxHeight: 200, overflow: 'auto'}}
treeData={gData} showSearch allowClear
treeData={gData} showSearch allowClear treeLine
value={this.state.value}
treeDefaultExpandAll={false}
placeholder={<i>请下拉选择</i>}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-tree-select",
"version": "1.2.3",
"version": "1.2.4",
"description": "tree-select ui component for react",
"keywords": [
"react",
Expand Down
16 changes: 2 additions & 14 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,6 @@ export function filterParentPosition(arr) {
return uniqueArray(a);
}

function containsPath(path1, path2) {
if (path2.length > path1.length) {
return false;
}
for (let i = 0; i < path2.length; i++) {
if (path1[i] !== path2[i]) {
return false;
}
}
return true;
}

const stripTail = (str) => {
const arr = str.match(/(.+)(-[^-]+)$/);
let st = '';
Expand All @@ -190,7 +178,7 @@ function handleCheckState(obj, checkedPosArr, checkIt) {
// 设置子节点,全选或全不选
Object.keys(obj).forEach((i) => {
const iPath = splitPos(i);
if (iPath.length > posPath.length && containsPath(iPath, posPath)) {
if (iPath.length > posPath.length && isInclude(posPath, iPath)) {
obj[i].checkPart = false;
obj[i].checked = checkIt;
}
Expand All @@ -207,7 +195,7 @@ function handleCheckState(obj, checkedPosArr, checkIt) {
const parentPosPath = splitPos(parentPos);
Object.keys(obj).forEach((i) => {
const iPath = splitPos(i);
if (iPath.length === _posLen && containsPath(iPath, parentPosPath)) {
if (iPath.length === _posLen && isInclude(parentPosPath, iPath)) {
sibling++;
if (obj[i].checked) {
siblingChecked++;
Expand Down

0 comments on commit c1fce85

Please sign in to comment.