Skip to content

Overwriting font-size styles in multiple CSS classes fails on Android #4234

@buuhuu

Description

@buuhuu

Assuming we have the following style defined:

.classA {
 font: 31 'icon-font';
}

Label.classB {
 font: 31 Arial
}

and the following template

<Label class="classA classB" text="Text"><Label>

This is giving me the following exception on Android using tns-core-modules 3.0.0.

JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'nativeSize' of undefined
JS: TypeError: Cannot read property 'nativeSize' of undefined
JS:     at Label.TextBase.(anonymous function) (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/text-base/text-base.js:137:91)
JS:     at Style.css:font-size (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js:649:46)
JS:     at Object.resetCSSProperties (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js:885:40)
JS:     at CssState.apply (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/styling/style-scope.js:91:22)
JS:     at file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:306:29
JS:     at Label.ViewBase._batchUpdate (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:216:20)
JS:     at Label.ViewBase.applyCssState (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:300:14)
JS:     at Label.ViewBase._setCssState (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:293:14)
JS:     at StyleScope.applySelectors (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/styling/style-scope.js:228:14)
JS:     at Label.ViewBase._applyStyleFromScope (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:233:19)
JS:     at resetStyles (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:699:10)
JS:     at file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:701:9
JS:     at GridLayout.LayoutBaseCommon.eachChildView (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/layouts/layout-base-common.js:125:26)
JS:     at GridLayout.ViewCommon.eachChild (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view/view-common.js:690:14)
JS:     at resetStyles (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:700:10)
JS:     at valueChanged (file:///data/data/ch.myapp.nc/files/app/tns_modules/tns-core-modules/ui/core/view-base/view-base.js:694:9)

From the stacktrace we can see that when applying the Style first resetCSSProperties is called setting the defaultValue to the View, which in that case is undefined and has no property nativeSize

See https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/ui/styling/style-properties.ts#L932

I have no clue why that is working properly on iOS.

Note: Worked with 2.5.x

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions