Nativescript: TNS 3.1 breaks background-color through css binding for iOS

Created on 24 Jun 2017  ยท  13Comments  ยท  Source: NativeScript/NativeScript

This is regarding the DropDown plugin. In TNS 3.0 binding the value of the class that has some background-color property defined worked flawlessly. Now after I've upgraded the demo project to 3.1 setting the background-color fails with the following error:

CONSOLE ERROR file:///app/tns_modules/tns-core-modules/trace/trace.js:165:30: Error: Failed to apply property [background-color
] with value [blue] to DropDown<dd>@file:///app/main-page.xml:3:5;. TypeError: value1.equals is not a function. (In 'value1.equ
als(value2)', 'value1.equals' is undefined)

After debugging the issue turns out that here: https://github.com/NativeScript/NativeScript/blob/b45cbe929b8a402ecb7019ee47f5a3de81052ce8/tns-core-modules/ui/core/properties/properties.ts#L595 the oldValue ends up an instance of UIColor instead of Color and thus the comparison is failing. I have not made any changes to the styling so it must be some of the changes to the TNS core that is messing up the value. In addition testing the same demo app with TNS 3.0 oldValue ends up correctly as an instance of Color

The issue can be easily simulated by using the demo project for the drop down and upgrading it to 3.1 and pressing Change Styles button once it runs.

backlog bug done ios high

Most helpful comment

@PeterStaev @tsonevn This isn't just iOS or a plugin issue. It's a general 3.1 issue, here's the test app: https://github.com/sserdyuk/ns-bug-4450

JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
Executing before-prepare hook from /home/sergei/Projects/Tests/SwitchBackgroundColor/hooks/before-prepare/nativescript-dev-typescript.js

All 13 comments

@PeterStaev @tsonevn This isn't just iOS or a plugin issue. It's a general 3.1 issue, here's the test app: https://github.com/sserdyuk/ns-bug-4450

JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
JS: Error: Failed to apply property [background-color] with value [red] to Switch(16)@file:///app/main-page.xml:7:9;. TypeError: value1.equals is not a function
Executing before-prepare hook from /home/sergei/Projects/Tests/SwitchBackgroundColor/hooks/before-prepare/nativescript-dev-typescript.js

@sserdyuk using your test application I was not able to reproduce the issue neither on Android (tested API19 and API25) or iOS.

@PeterStaev I have also tried to reproduce the issue using your demo project but I was not able to run the demo (entry point error) so I have made this test project based on your demo logic. However, the issue is not preproducible (tested both iOS and Android - can you take a look at the test project and let me know if you can reproduce the issue?

@NickIliev , sorry but I cannot download the test project as it is included in one huge repo and I do not want to download everything...

Attaching the demo project from the DropDown repo with updated deps. So simply run tns run ios and then press Change Styles in the app.
demo.zip

@NickIliev Did you check the log in the terminal? The switch does change color, so it's working as expected, but each time you toggle it, an error is printed in the terminal.

Yes, sometimes styles are changed, sometimes the widget is totally messed up. So the error does not crash the app, but still seems a problem with the applying the styles.

@manijak - does any of this look familiar from the cardview debugging you did last week?

App to reproduce the issue can be found in this linked issue

@NickIliev Any update on this issue?

+1 reproducible also on Android via SB template

sample application here

Steps to reproduce:

  • go to "Edit" and use the slider (Android)

@tsonevn I was using debugger for other reasons and stopped on this exception. Hopefully you can fix it quick, seems like Color.equals is called with a wrong type of parameter. I

image

$ tns info
All NativeScript components versions information
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Component        โ”‚ Current version โ”‚ Latest version โ”‚ Information โ”‚
โ”‚ nativescript     โ”‚ 3.1.2           โ”‚ 3.1.2          โ”‚ Up to date  โ”‚
โ”‚ tns-core-modules โ”‚ 3.1.0           โ”‚ 3.1.0          โ”‚ Up to date  โ”‚
โ”‚ tns-android      โ”‚ 3.1.1           โ”‚ 3.1.1          โ”‚ Up to date  โ”‚
โ”‚ tns-ios          โ”‚ 3.1.0           โ”‚ 3.1.0          โ”‚ Up to date  โ”‚

The fix is already available in tns-core-modules@next and will be released officially with [email protected].

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

NickIliev picture NickIliev  ยท  3Comments

nirsalon picture nirsalon  ยท  3Comments

rLoka picture rLoka  ยท  3Comments

Pourya8366 picture Pourya8366  ยท  3Comments

tsonevn picture tsonevn  ยท  3Comments