From 49576d208794a2302dd37550935565a7628ebf3c Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Fri, 15 May 2015 11:13:53 +0300 Subject: [PATCH 1/4] support for platform specific attributes added --- tsconfig.json | 4 ++++ ui/builder/component-builder.ts | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/tsconfig.json b/tsconfig.json index f5f19ea65..39d74ba01 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -159,6 +159,7 @@ "./apps/tests/pages/page15.ts", "./apps/tests/pages/page16.ts", "./apps/tests/pages/page17.ts", + "./apps/tests/pages/page18.ts", "./apps/tests/pages/page5.ts", "./apps/tests/pages/page6.ts", "./apps/tests/pages/page7.ts", @@ -176,6 +177,9 @@ "./apps/tests/ui-test.ts", "./apps/tests/ui/activity-indicator/activity-indicator-tests.ts", "./apps/tests/ui/bindable-tests.ts", + "./apps/tests/ui/bindingContext_testPage.ts", + "./apps/tests/ui/bindingContext_testPage1.ts", + "./apps/tests/ui/bindingContext_testPage2.ts", "./apps/tests/ui/border/border-tests.ts", "./apps/tests/ui/button/button-tests-native.android.ts", "./apps/tests/ui/button/button-tests-native.d.ts", diff --git a/ui/builder/component-builder.ts b/ui/builder/component-builder.ts index ee1672cf6..afbabad5e 100644 --- a/ui/builder/component-builder.ts +++ b/ui/builder/component-builder.ts @@ -9,6 +9,7 @@ import definition = require("ui/builder/component-builder"); import fs = require("file-system"); import gestures = require("ui/gestures"); import bindingBuilder = require("ui/builder/binding-builder"); +import platform = require("platform"); var EVENT = "Event"; var UI_PATH = "ui/"; @@ -76,6 +77,13 @@ export function getComponentModule(elementName: string, namespace: string, attri var attrValue = attributes[attr]; + if (attr.indexOf(":") !== -1){ + var platformName = attr.split(":")[0].trim(); + if(platformName.toLowerCase() !== platform.device.os.toLowerCase()) { + continue; + } + } + if (attr.indexOf(".") !== -1) { var subObj = instance; var properties = attr.split("."); From 17b53bcb411abb108846f18a2edbc391cb1acc06 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Fri, 15 May 2015 11:34:55 +0300 Subject: [PATCH 2/4] test added --- .../tests/xml-declaration/xml-declaration-tests.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/tests/xml-declaration/xml-declaration-tests.ts b/apps/tests/xml-declaration/xml-declaration-tests.ts index a0600b51b..fea769541 100644 --- a/apps/tests/xml-declaration/xml-declaration-tests.ts +++ b/apps/tests/xml-declaration/xml-declaration-tests.ts @@ -17,6 +17,7 @@ import myCustomControlWithoutXml = require("./mymodule/MyControl"); import listViewModule = require("ui/list-view"); import helper = require("../ui/helper"); import viewModule = require("ui/core/view"); +import platform = require("platform"); export function test_load_IsDefined() { TKUnit.assert(types.isFunction(builder.load), "ui/builder should have load method!"); @@ -129,6 +130,17 @@ export function test_parse_ShouldParseBooleanPropertiesIgnoreCaseInverted() { TKUnit.assert(tf.editable === false, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); }; +export function test_parse_ShouldParsePlatofmrSpecificProperties() { + var p = builder.parse(""); + var tf = p.content; + + if(platform.device.os === platform.platformNames.ios) { + TKUnit.assert(tf.editable === true, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); + } else { + TKUnit.assert(tf.editable === false, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); + } +}; + export function test_parse_ShouldParseBindings() { var p = builder.parse(""); p.bindingContext = { myProp: true }; @@ -295,4 +307,4 @@ export function test_parse_ShouldParseNestedListViewInListViewTemplate() { finally { helper.goBack(); } -} \ No newline at end of file +} From 3a80949ee75b9783ad9b3b861d6ad5b486464d1e Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Fri, 15 May 2015 13:37:28 +0300 Subject: [PATCH 3/4] test fixed --- apps/tests/xml-declaration/xml-declaration-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/tests/xml-declaration/xml-declaration-tests.ts b/apps/tests/xml-declaration/xml-declaration-tests.ts index fea769541..a22ee3190 100644 --- a/apps/tests/xml-declaration/xml-declaration-tests.ts +++ b/apps/tests/xml-declaration/xml-declaration-tests.ts @@ -135,7 +135,7 @@ export function test_parse_ShouldParsePlatofmrSpecificProperties() { var tf = p.content; if(platform.device.os === platform.platformNames.ios) { - TKUnit.assert(tf.editable === true, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); + TKUnit.assert(tf.editable === true, "Expected result: true; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); } else { TKUnit.assert(tf.editable === false, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); } From dd9e70fc6c814593eadfcf9354f70e7cde7fb99a Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Fri, 15 May 2015 17:27:26 +0300 Subject: [PATCH 4/4] more fixes --- .../tests/xml-declaration/xml-declaration-tests.ts | 8 ++++---- ui/builder/component-builder.ts | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/tests/xml-declaration/xml-declaration-tests.ts b/apps/tests/xml-declaration/xml-declaration-tests.ts index a22ee3190..269def545 100644 --- a/apps/tests/xml-declaration/xml-declaration-tests.ts +++ b/apps/tests/xml-declaration/xml-declaration-tests.ts @@ -130,14 +130,14 @@ export function test_parse_ShouldParseBooleanPropertiesIgnoreCaseInverted() { TKUnit.assert(tf.editable === false, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); }; -export function test_parse_ShouldParsePlatofmrSpecificProperties() { +export function test_parse_ShouldParsePlatformSpecificProperties() { var p = builder.parse(""); var tf = p.content; - if(platform.device.os === platform.platformNames.ios) { - TKUnit.assert(tf.editable === true, "Expected result: true; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); + if (platform.device.os === platform.platformNames.ios) { + TKUnit.assert(tf.editable === false, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); } else { - TKUnit.assert(tf.editable === false, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); + TKUnit.assert(tf.editable === true, "Expected result: true; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); } }; diff --git a/ui/builder/component-builder.ts b/ui/builder/component-builder.ts index afbabad5e..e926ed8fe 100644 --- a/ui/builder/component-builder.ts +++ b/ui/builder/component-builder.ts @@ -77,12 +77,14 @@ export function getComponentModule(elementName: string, namespace: string, attri var attrValue = attributes[attr]; - if (attr.indexOf(":") !== -1){ - var platformName = attr.split(":")[0].trim(); - if(platformName.toLowerCase() !== platform.device.os.toLowerCase()) { - continue; - } - } + if (attr.indexOf(":") !== -1) { + var platformName = attr.split(":")[0].trim(); + if (platformName.toLowerCase() === platform.device.os.toLowerCase()) { + attr = attr.split(":")[1].trim(); + } else { + continue; + } + } if (attr.indexOf(".") !== -1) { var subObj = instance;