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
19a28a7f
authored
2012-11-08 19:46:02 -0800
by
Michael Richards
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'fix-unbind'
2 parents
a7963f51
3ae30db0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
spec/index.html
spec/rivets/binders.js
src/rivets.coffee
spec/index.html
View file @
19a28a7
...
...
@@ -15,6 +15,7 @@
<script
type=
"text/javascript"
src=
"matchers.js"
></script>
<script
type=
"text/javascript"
src=
"mock.data.js"
></script>
<script
type=
"text/javascript"
src=
"rivets/binding.js"
></script>
<script
type=
"text/javascript"
src=
"rivets/binders.js"
></script>
<script
type=
"text/javascript"
src=
"rivets/routines.js"
></script>
<script
type=
"text/javascript"
src=
"rivets/functional.js"
></script>
...
...
spec/rivets/binders.js
0 → 100644
View file @
19a28a7
describe
(
"Rives.binders"
,
function
()
{
var
context
;
beforeEach
(
function
()
{
context
=
{
publish
:
function
()
{}
}
});
describe
(
"value"
,
function
()
{
var
el
;
beforeEach
(
function
()
{
el
=
document
.
createElement
(
'input'
);
});
it
(
"unbinds the same bound function"
,
function
()
{
var
boundFn
;
spyOn
(
el
,
'addEventListener'
).
andCallFake
(
function
(
event
,
fn
)
{
boundFn
=
fn
;
});
rivets
.
binders
.
value
.
bind
.
call
(
context
,
el
);
spyOn
(
el
,
'removeEventListener'
).
andCallFake
(
function
(
event
,
fn
)
{
expect
(
fn
).
toBe
(
boundFn
);
});
rivets
.
binders
.
value
.
unbind
.
call
(
context
,
el
);
});
});
});
\ No newline at end of file
src/rivets.coffee
View file @
19a28a7
...
...
@@ -243,9 +243,9 @@ Rivets.binders =
checked
:
publishes
:
true
bind
:
(
el
)
->
bindEvent
el
,
'change'
,
@
publish
@
currentListener
=
bindEvent
el
,
'change'
,
@
publish
unbind
:
(
el
)
->
unbindEvent
el
,
'change'
,
@
publish
unbindEvent
el
,
'change'
,
@
currentListener
routine
:
(
el
,
value
)
->
if
el
.
type
is
'radio'
el
.
checked
=
el
.
value
is
value
...
...
@@ -255,9 +255,9 @@ Rivets.binders =
unchecked
:
publishes
:
true
bind
:
(
el
)
->
bindEvent
el
,
'change'
,
@
publish
@
currentListener
=
bindEvent
el
,
'change'
,
@
publish
unbind
:
(
el
)
->
unbindEvent
el
,
'change'
,
@
publish
unbindEvent
el
,
'change'
,
@
currentListener
routine
:
(
el
,
value
)
->
if
el
.
type
is
'radio'
el
.
checked
=
el
.
value
isnt
value
...
...
@@ -276,9 +276,9 @@ Rivets.binders =
value
:
publishes
:
true
bind
:
(
el
)
->
bindEvent
el
,
'change'
,
@
publish
@
currentListener
=
bindEvent
el
,
'change'
,
@
publish
unbind
:
(
el
)
->
unbindEvent
el
,
'change'
,
@
publish
unbindEvent
el
,
'change'
,
@
currentListener
routine
:
(
el
,
value
)
->
if
el
.
type
is
'select-multiple'
o
.
selected
=
o
.
value
in
value
for
o
in
el
if
value
?
...
...
Please
register
or
sign in
to post a comment