mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Merge pull request #168 from NativeScript/platform-specific-attributes
support for platform specific attributes added
This commit is contained in:
@ -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_ShouldParsePlatformSpecificProperties() {
|
||||
var p = <page.Page>builder.parse("<Page><TextField ios:editable='False' android:editable='True' /></Page>");
|
||||
var tf = <textFieldModule.TextField>p.content;
|
||||
|
||||
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 === true, "Expected result: true; Actual result: " + tf.editable + "; type: " + typeof (tf.editable));
|
||||
}
|
||||
};
|
||||
|
||||
export function test_parse_ShouldParseBindings() {
|
||||
var p = <page.Page>builder.parse("<Page><Switch checked='{{ myProp }}' /></Page>");
|
||||
p.bindingContext = { myProp: true };
|
||||
@ -295,4 +307,4 @@ export function test_parse_ShouldParseNestedListViewInListViewTemplate() {
|
||||
finally {
|
||||
helper.goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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,15 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
||||
|
||||
var attrValue = <string>attributes[attr];
|
||||
|
||||
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;
|
||||
var properties = attr.split(".");
|
||||
|
Reference in New Issue
Block a user