This repository was archived by the owner on Mar 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var React = require ( 'react' ) ;
4
+ var ou = require ( '../objectUtils' ) ;
4
5
var $ = React . DOM ;
5
6
6
7
var normalizer = require ( './utils/normalizer' ) ;
@@ -26,10 +27,11 @@ var InputField = React.createClass({
26
27
}
27
28
} ,
28
29
render : function ( ) {
30
+ var value = ou . isNil ( this . props . value ) ? '' : this . props . value ;
29
31
return $ . input ( {
30
32
type : "text" ,
31
33
name : this . props . label ,
32
- value : this . props . value || '' ,
34
+ value : value ,
33
35
onKeyPress : this . handleKeyPress ,
34
36
onChange : this . handleChange } ) ;
35
37
}
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var normalizer = require ( './normalizer' ) ;
4
-
4
+ var ou = require ( '../../objectUtils' ) ;
5
5
6
6
exports . string = function ( text ) {
7
7
return normalizer . string ( text ) ;
8
8
} ;
9
9
10
10
exports . integer = function ( text ) {
11
- return text ? parseInt ( normalizer . integer ( text ) ) : null ;
11
+ return ou . isNil ( text ) ? null : parseInt ( normalizer . integer ( text ) ) ;
12
12
} ;
13
13
14
14
exports . number = function ( text ) {
15
- return text ? parseFloat ( normalizer . number ( text ) ) : null ;
15
+ return ou . isNil ( text ) ? null : parseFloat ( normalizer . number ( text ) ) ;
16
16
} ;
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ var isNat = function(x) {
24
24
return typeof x == 'number' && x >= 0 && x % 1 == 0 ;
25
25
} ;
26
26
27
+ var isNil = function ( x ) {
28
+ return ( typeof x === 'undefined' || x === null ) ;
29
+ } ;
30
+
27
31
var object = function ( ) {
28
32
var args = Array . prototype . slice . call ( arguments ) ;
29
33
var result = [ ] ;
@@ -158,5 +162,6 @@ module.exports = {
158
162
prune : prune ,
159
163
split : split ,
160
164
map : map ,
161
- mapKeys : mapKeys
165
+ mapKeys : mapKeys ,
166
+ isNil : isNil
162
167
} ;
You can’t perform that action at this time.
0 commit comments