mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Prevent app crash for css text-transform (#6815)
* Prevent app crash for css text-transform * refactor: formatting * refactor: formatting * minor refactoring * fix: use isString - text is sometimes String * fix: use isString - text is sometimes String
This commit is contained in:

committed by
Svetoslav

parent
cea97c6b45
commit
9f8d24a811
@ -7,6 +7,7 @@ import {
|
|||||||
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length,
|
paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length,
|
||||||
whiteSpaceProperty, lineHeightProperty, FormattedString, layout, Span, Color, isBold, resetSymbol
|
whiteSpaceProperty, lineHeightProperty, FormattedString, layout, Span, Color, isBold, resetSymbol
|
||||||
} from "./text-base-common";
|
} from "./text-base-common";
|
||||||
|
import { isString } from "../../utils/types";
|
||||||
|
|
||||||
export * from "./text-base-common";
|
export * from "./text-base-common";
|
||||||
|
|
||||||
@ -323,6 +324,10 @@ function getCapitalizedString(str: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getTransformedText(text: string, textTransform: TextTransform): string {
|
export function getTransformedText(text: string, textTransform: TextTransform): string {
|
||||||
|
if (!text || !isString(text)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
switch (textTransform) {
|
switch (textTransform) {
|
||||||
case "uppercase":
|
case "uppercase":
|
||||||
return text.toUpperCase();
|
return text.toUpperCase();
|
||||||
@ -439,4 +444,4 @@ function setSpanModifiers(ssb: android.text.SpannableStringBuilder, span: Span,
|
|||||||
// if (letterSpacing > 0) {
|
// if (letterSpacing > 0) {
|
||||||
// ssb.setSpan(new android.text.style.ScaleXSpan((letterSpacing + 1) / 10), start, end, android.text.Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
// ssb.setSpan(new android.text.style.ScaleXSpan((letterSpacing + 1) / 10), start, end, android.text.Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, lineHeightProperty,
|
textTransformProperty, letterSpacingProperty, colorProperty, fontInternalProperty, lineHeightProperty,
|
||||||
FormattedString, Span, Color, isBold, resetSymbol
|
FormattedString, Span, Color, isBold, resetSymbol
|
||||||
} from "./text-base-common";
|
} from "./text-base-common";
|
||||||
|
import { isString } from "../../utils/types";
|
||||||
|
|
||||||
export * from "./text-base-common";
|
export * from "./text-base-common";
|
||||||
|
|
||||||
@ -298,6 +299,10 @@ export class TextBase extends TextBaseCommon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getTransformedText(text: string, textTransform: TextTransform): string {
|
export function getTransformedText(text: string, textTransform: TextTransform): string {
|
||||||
|
if (!text || !isString(text)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
switch (textTransform) {
|
switch (textTransform) {
|
||||||
case "uppercase":
|
case "uppercase":
|
||||||
return NSStringFromNSAttributedString(text).uppercaseString;
|
return NSStringFromNSAttributedString(text).uppercaseString;
|
||||||
|
Reference in New Issue
Block a user