This commit is contained in:
Vladimir Enchev
2015-08-07 10:00:44 +03:00
parent 2a106ea356
commit 24cb7bb591
2 changed files with 39 additions and 1 deletions

View File

@@ -312,6 +312,30 @@ export function test_parse_ShouldParseSubProperties() {
TKUnit.assert(sw.visibility === "collapsed", "Expected result: collapsed; Actual result: " + sw.visibility + "; type: " + typeof (sw.visibility));
};
export function test_parse_ShouldParseBindingsWithCommaInsideSingleQuote() {
var expected = "Hi,test"
var bindingString = "{{ 'Hi,' + myProp }}";
var p = <page.Page>builder.parse('<Page><Label text="' + bindingString + '" /></Page>');
var obj = new observable.Observable();
obj.set("myProp", "test");
p.bindingContext = obj;
var lbl = <labelModule.Label>p.content;
TKUnit.assert(lbl.text === expected, "Expected " + expected + "; Actual result: " + lbl.text + "; type: " + typeof (lbl.text));
};
export function test_parse_ShouldParseBindingsWithCommaInsideDoubleQuote() {
var expected = "Hi,test"
var bindingString = '{{ "Hi," + myProp }}';
var p = <page.Page>builder.parse("<Page><Label text='" + bindingString + "' /></Page>");
var obj = new observable.Observable();
obj.set("myProp", "test");
p.bindingContext = obj;
var lbl = <labelModule.Label>p.content;
TKUnit.assert(lbl.text === expected, "Expected " + expected + "; Actual result: " + lbl.text + "; type: " + typeof (lbl.text));
};
export function test_parse_CanBindBackgroundImage() {
var p = <page.Page>builder.parse("<Page><StackLayout backgroundImage='{{ myProp }}' /></Page>");
var expected = "~/logo.png"

View File

@@ -96,19 +96,33 @@ function getParamsArray(value: string) {
var i;
var skipComma = 0;
var indexReached = 0;
var singleQuoteBlock, doubleQuoteBlock = false;
for (i = 0; i < value.length; i++) {
if (value[i] === '"') {
doubleQuoteBlock = !doubleQuoteBlock;
}
if (value[i] === "'") {
singleQuoteBlock = !singleQuoteBlock;
}
if (value[i] === '(' || value[i] === '[') {
skipComma++;
}
if (value[i] === ')' || value[i] === ']') {
skipComma--;
}
if (value[i] === ',' && skipComma === 0) {
if (value[i] === ',' && skipComma === 0 && !(singleQuoteBlock || doubleQuoteBlock)) {
result.push(value.substr(indexReached, i - indexReached));
indexReached = i + 1;
}
}
result.push(value.substr(indexReached));
return result;
}