diff --git a/tns-core-modules/ui/text-base/text-base.android.ts b/tns-core-modules/ui/text-base/text-base.android.ts index 61131348e..fb47d8c89 100644 --- a/tns-core-modules/ui/text-base/text-base.android.ts +++ b/tns-core-modules/ui/text-base/text-base.android.ts @@ -7,6 +7,7 @@ import { paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length, whiteSpaceProperty, lineHeightProperty, FormattedString, layout, Span, Color, isBold, resetSymbol } from "./text-base-common"; +import { isString } from "../../utils/types"; export * from "./text-base-common"; @@ -323,6 +324,10 @@ function getCapitalizedString(str: string): string { } export function getTransformedText(text: string, textTransform: TextTransform): string { + if (!text || !isString(text)) { + return ""; + } + switch (textTransform) { case "uppercase": return text.toUpperCase(); @@ -439,4 +444,4 @@ function setSpanModifiers(ssb: android.text.SpannableStringBuilder, span: Span, // if (letterSpacing > 0) { // ssb.setSpan(new android.text.style.ScaleXSpan((letterSpacing + 1) / 10), start, end, android.text.Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); // } -} \ No newline at end of file +} diff --git a/tns-core-modules/ui/text-base/text-base.ios.ts b/tns-core-modules/ui/text-base/text-base.ios.ts index 97f4d13a0..446f9b794 100644 --- a/tns-core-modules/ui/text-base/text-base.ios.ts +++ b/tns-core-modules/ui/text-base/text-base.ios.ts @@ -5,6 +5,7 @@ import { textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, lineHeightProperty, FormattedString, Span, Color, isBold, resetSymbol } from "./text-base-common"; +import { isString } from "../../utils/types"; export * from "./text-base-common"; @@ -298,6 +299,10 @@ export class TextBase extends TextBaseCommon { } export function getTransformedText(text: string, textTransform: TextTransform): string { + if (!text || !isString(text)) { + return ""; + } + switch (textTransform) { case "uppercase": return NSStringFromNSAttributedString(text).uppercaseString;