Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
a331169a
Commit
a331169a
authored
Jan 20, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改setData和修复getCommonAncestor
parent
14fba533
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
12 deletions
+39
-12
node.js
spec/core/node.js
+25
-4
node.js
src/core/node.js
+14
-8
No files found.
spec/core/node.js
View file @
a331169a
...
@@ -20,7 +20,7 @@ describe("node", function () {
...
@@ -20,7 +20,7 @@ describe("node", function () {
it
(
'first contain first'
,
function
(){
it
(
'first contain first'
,
function
(){
expect
(
first
.
contains
(
first
)).
toBeTruthy
();
expect
(
first
.
contains
(
first
)).
toBeTruthy
();
});
});
})
})
;
describe
(
'getCommonAncestor'
,
function
(){
describe
(
'getCommonAncestor'
,
function
(){
it
(
'first second commonAncestor is root'
,
function
(){
it
(
'first second commonAncestor is root'
,
function
(){
expect
(
first
.
getCommonAncestor
(
second
)).
toBe
(
root
);
expect
(
first
.
getCommonAncestor
(
second
)).
toBe
(
root
);
...
@@ -30,9 +30,30 @@ describe("node", function () {
...
@@ -30,9 +30,30 @@ describe("node", function () {
});
});
it
(
'second.first first.first commonAncestor is root'
,
function
(){
it
(
'second.first first.first commonAncestor is root'
,
function
(){
var
a
=
first
.
getFirstChild
(),
b
=
second
.
getFirstChild
();
var
a
=
first
.
getFirstChild
(),
b
=
second
.
getFirstChild
();
debugger
var
c
=
a
.
getCommonAncestor
(
b
);
expect
(
a
.
getCommonAncestor
(
b
)).
toBe
(
root
);
expect
(
a
.
getCommonAncestor
(
b
)).
toBe
(
root
);
});
});
})
});
describe
(
'setData'
,
function
(){
it
(
'name and value both exist'
,
function
(){
root
.
setData
(
'test'
,
1
);
expect
(
root
.
getData
(
'test'
)).
toBe
(
1
);
});
it
(
'name only exist clear property'
,
function
(){
root
.
setData
(
'test'
);
expect
(
root
.
getData
(
'test'
)).
toBeUndefined
();
});
it
(
'name is object'
,
function
(){
root
.
setData
({
'test'
:
1
});
expect
(
root
.
getData
(
'test'
)).
toBe
(
1
);
});
it
(
'name and value both empty'
,
function
(){
root
.
setData
(
'test'
,
1
);
root
.
setData
(
'test1'
,
2
);
root
.
setData
();
expect
(
root
.
getData
(
'test'
)).
toBeUndefined
();
expect
(
root
.
getData
(
'test1'
)).
toBeUndefined
();
});
});
});
});
\ No newline at end of file
src/core/node.js
View file @
a331169a
...
@@ -137,13 +137,19 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -137,13 +137,19 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
},
},
setData
:
function
(
name
,
value
)
{
setData
:
function
(
name
,
value
)
{
if
(
arguments
.
length
==
1
&&
typeof
(
arguments
[
0
]
)
==
'object'
)
{
if
(
name
===
undefined
){
Utils
.
extend
(
this
.
data
,
arguments
[
0
]
);
this
.
data
=
{}
}
else
if
(
utils
.
isObject
(
name
)){
utils
.
extend
(
this
.
data
,
name
)
}
else
{
if
(
value
===
undefined
){
this
.
data
[
name
]
=
null
;
delete
this
.
data
[
name
]
}
else
{
this
.
data
[
name
]
=
value
;
}
}
}
this
.
data
[
name
]
=
value
;
},
clearData
:
function
()
{
this
.
data
=
{};
},
},
getRenderContainer
:
function
()
{
getRenderContainer
:
function
()
{
return
this
.
rc
;
return
this
.
rc
;
...
@@ -158,9 +164,9 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
...
@@ -158,9 +164,9 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
if
(
node
.
contains
(
this
)
)
{
if
(
node
.
contains
(
this
)
)
{
return
node
return
node
}
}
var
parent
=
node
.
parent
;
var
parent
=
this
.
parent
;
while
(
!
parent
.
contains
(
node
)
)
{
while
(
!
parent
.
contains
(
node
)
)
{
parent
=
parent
.
parent
Node
;
parent
=
parent
.
parent
;
}
}
return
parent
;
return
parent
;
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment