Skip to content

Commit eba3bb3

Browse files
committed
Make StringParser parse empty string as null
This patch changes the StringParser to return null when the given string is empty. Bug: T93572
1 parent 65ecb1f commit eba3bb3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/valueParsers/parsers/StringParser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ vp.StringParser = util.inherit( PARENT, {
2020
* @param {string} rawValue
2121
*/
2222
parse: function( rawValue ) {
23-
return $.Deferred().resolve( new dv.StringValue( rawValue ) ).promise();
23+
return $.Deferred().resolve(
24+
rawValue === '' ? null : new dv.StringValue( rawValue )
25+
).promise();
2426
}
2527
} );
2628

tests/src/valueParsers/parsers/StringParser.tests.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ define( [
3838
[ '42', new dv.StringValue( '42' ) ],
3939
[ ' foo ', new dv.StringValue( ' foo ' ) ],
4040
[ ' Baa', new dv.StringValue( ' Baa' ) ],
41-
[ 'xXx ', new dv.StringValue( 'xXx ' ) ]
41+
[ 'xXx ', new dv.StringValue( 'xXx ' ) ],
42+
[ '', null ]
4243
];
4344
}
4445

0 commit comments

Comments
 (0)