Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
14b3c772
authored
2013-01-11 20:18:16 -0800
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #111 from terrancesnyder/Issue#110
Pull request for #110
2 parents
835f5406
36de3dba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
11 deletions
spec/rivets/functional.js
src/rivets.coffee
spec/rivets/functional.js
View file @
14b3c77
...
...
@@ -116,6 +116,12 @@ describe('Functional', function() {
expect
(
el
.
getElementsByTagName
(
'li'
).
length
).
toBe
(
2
);
});
it
(
'should not fail if the collection being bound to is null'
,
function
()
{
data
.
set
({
items
:
null
});
rivets
.
bind
(
el
,
bindData
);
expect
(
el
.
getElementsByTagName
(
'li'
).
length
).
toBe
(
0
);
});
it
(
'should re-loop over the collection and create new instances when the array changes'
,
function
()
{
rivets
.
bind
(
el
,
bindData
);
expect
(
el
.
getElementsByTagName
(
'li'
).
length
).
toBe
(
2
);
...
...
@@ -162,6 +168,7 @@ describe('Functional', function() {
expect
(
el
.
getElementsByTagName
(
'li'
)[
2
]).
toHaveTheTextContent
(
'b'
);
expect
(
el
.
getElementsByTagName
(
'li'
)[
3
]).
toHaveTheTextContent
(
'last'
);
})
});
});
...
...
src/rivets.coffee
View file @
14b3c77
...
...
@@ -339,17 +339,18 @@ Rivets.binders =
@
iterated
=
[]
for
item
in
collection
data
=
{}
data
[
n
]
=
m
for
n
,
m
of
@
view
.
models
data
[
@
args
[
0
]]
=
item
itemEl
=
el
.
cloneNode
true
if
@
iterated
.
length
>
0
previous
=
@
iterated
[
@
iterated
.
length
-
1
].
els
[
0
]
else
previous
=
@
marker
@
marker
.
parentNode
.
insertBefore
itemEl
,
previous
.
nextSibling
?
null
@
iterated
.
push
rivets
.
bind
itemEl
,
data
if
collection
for
item
in
collection
data
=
{}
data
[
n
]
=
m
for
n
,
m
of
@
view
.
models
data
[
@
args
[
0
]]
=
item
itemEl
=
el
.
cloneNode
true
if
@
iterated
.
length
>
0
previous
=
@
iterated
[
@
iterated
.
length
-
1
].
els
[
0
]
else
previous
=
@
marker
@
marker
.
parentNode
.
insertBefore
itemEl
,
previous
.
nextSibling
?
null
@
iterated
.
push
rivets
.
bind
itemEl
,
data
"class-*"
:
(
el
,
value
)
->
elClass
=
"
#{
el
.
className
}
"
...
...
Please
register
or
sign in
to post a comment