Skip to content

Commit 646fbc5

Browse files
author
Vlad Balin
committed
added event passthroug to link,action
1 parent 322d607 commit 646fbc5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Linked.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exports.Input = ( { invalid = 'invalid', className = '', valueLink, checkedLink,
1515
return <input {...props}
1616
className={ className }
1717
checked={ link.value === props.value }
18-
onChange={ e => e.target.checked && link.set( props.value ) }/>;
18+
onChange={ e => { if( e.target.checked ) link.set( props.value ); } }/>;
1919

2020
default:
2121
return <input {...props}

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ Link.prototype = {
3030
set : doNothing,
3131

3232
// Immediately update the link
33-
update : function( transform ){
34-
var nextValue = transform( link.value );
33+
update : function( transform, e ){
34+
var nextValue = transform( link.value, e );
3535
nextValue === void 0 || link.set( nextValue );
3636
},
3737

3838
// Create action function which will updates the link
39+
// link.action( x => !x )
40+
// link.action( ( x, e ) => e.target.value )
3941
action : function( transform ){
4042
var link = this;
41-
return function(){ link.update( transform ) };
43+
return function( e ){ link.update( transform, e ) };
4244
},
4345

4446
// React backward compatibility shim

0 commit comments

Comments
 (0)