diff --git a/nativescript-angular/view-util.ts b/nativescript-angular/view-util.ts index 34d7c3de3..e604d81d8 100644 --- a/nativescript-angular/view-util.ts +++ b/nativescript-angular/view-util.ts @@ -10,8 +10,8 @@ import {ValueSource} from "ui/core/dependency-observable"; import {platformNames, Device} from "platform"; import {rendererLog as traceLog, styleError} from "./trace"; -const IOS_PREFX: string = "@ios:"; -const ANDROID_PREFX: string = "@android:"; +const IOS_PREFX: string = ":ios:"; +const ANDROID_PREFX: string = ":android:"; const whiteSpaceSplitter = /\s+/; export type ViewExtensions = ViewExtensions; diff --git a/tests/app/tests/platform-filter-components.ts b/tests/app/tests/platform-filter-components.ts index e65bb31cf..0c520255f 100644 --- a/tests/app/tests/platform-filter-components.ts +++ b/tests/app/tests/platform-filter-components.ts @@ -27,15 +27,24 @@ export class AndroidSpecificComponent { constructor(public elementRef: ElementRef) { } } +@Component({ + template: ` + + + ` +}) +export class PlatformSpecificAttributeComponent { + constructor(public elementRef: ElementRef) { } +} -describe('Platofrm filter components', () => { +describe('Platofrm filter directives', () => { describe('on IOS device', () => { let testApp: TestApp = null; before(() => { return TestApp.create([provide(DEVICE, { useValue: createDevice(platformNames.ios) })]).then((app) => { testApp = app; - }) + }); }); after(() => { @@ -59,7 +68,17 @@ describe('Platofrm filter components', () => { dumpView(componentRoot, true)); }); }); - }) + + + it("applies iOS specific attribute", () => { + return testApp.loadComponent(PlatformSpecificAttributeComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.equal( + "(ProxyViewContainer (StackLayout (Label[text=IOS])))", + dumpView(componentRoot, true)); + }); + }); + }); describe('on Android device', () => { let testApp: TestApp = null; @@ -67,7 +86,7 @@ describe('Platofrm filter components', () => { before(() => { return TestApp.create([provide(DEVICE, { useValue: createDevice(platformNames.android) })]).then((app) => { testApp = app; - }) + }); }); after(() => { @@ -91,5 +110,14 @@ describe('Platofrm filter components', () => { dumpView(componentRoot, true)); }); }); - }) -}) + + it("applies Android specific attribute", () => { + return testApp.loadComponent(PlatformSpecificAttributeComponent).then((componentRef) => { + const componentRoot = componentRef.instance.elementRef.nativeElement; + assert.equal( + "(ProxyViewContainer (StackLayout (Label[text=ANDROID])))", + dumpView(componentRoot, true)); + }); + }); + }); +}); diff --git a/tests/app/tests/property-sets.ts b/tests/app/tests/property-sets.ts index bcb06582c..de3364fc6 100644 --- a/tests/app/tests/property-sets.ts +++ b/tests/app/tests/property-sets.ts @@ -87,28 +87,28 @@ describe('setting View properties', () => { it('sets ios property in ios', () => { let view = new TestView(); let testUtil = new ViewUtil(iosDevice); - testUtil.setProperty(view, "@ios:anyValue", "blah"); + testUtil.setProperty(view, ":ios:anyValue", "blah"); assert.strictEqual("blah", view.anyValue); }); it('doesn\'t set android property in ios', () => { let view = new TestView(); let testUtil = new ViewUtil(iosDevice); - testUtil.setProperty(view, "@android:anyValue", "blah"); + testUtil.setProperty(view, ":android:anyValue", "blah"); assert.isUndefined(view.anyValue); }); it('sets android property in android', () => { let view = new TestView(); let testUtil = new ViewUtil(androidDevice); - testUtil.setProperty(view, "@android:anyValue", "blah"); + testUtil.setProperty(view, ":android:anyValue", "blah"); assert.strictEqual("blah", view.anyValue); }); it('doesn\'t set ios property in android', () => { let view = new TestView(); let testUtil = new ViewUtil(androidDevice); - testUtil.setProperty(view, "@ios:anyValue", "blah"); + testUtil.setProperty(view, ":ios:anyValue", "blah"); assert.isUndefined(view.anyValue); }); });