From 01c4b8ceb539d5cc64de4e62047414b641c589e1 Mon Sep 17 00:00:00 2001 From: "Bundyo (Kamen Bundev)" Date: Mon, 24 Jun 2019 11:52:33 +0300 Subject: [PATCH] fix(formatted-string) allow Span descendants in FormattedString (#7370) * (fix) Allow Span descendants in FormattedString Currently FormattedString doesn't allow custom components extending Span to be its children. This small PR fixes that. Closes #7369. * Remove the now unused CHILD_SPAN --- tns-core-modules/text/formatted-string.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tns-core-modules/text/formatted-string.ts b/tns-core-modules/text/formatted-string.ts index 2d4d62b00..01b2638b9 100644 --- a/tns-core-modules/text/formatted-string.ts +++ b/tns-core-modules/text/formatted-string.ts @@ -13,8 +13,6 @@ export module knownCollections { export const spans = "spans"; } -const CHILD_SPAN = "Span"; - export class FormattedString extends ViewBase implements FormattedStringDefinition, AddArrayFromBuilder, AddChildFromBuilder { private _spans: ObservableArray; @@ -95,7 +93,7 @@ export class FormattedString extends ViewBase implements FormattedStringDefiniti } public _addChildFromBuilder(name: string, value: any): void { - if (name === CHILD_SPAN) { + if (value instanceof Span) { this.spans.push(value); } } @@ -109,7 +107,7 @@ export class FormattedString extends ViewBase implements FormattedStringDefiniti this._addView(span); // Then attach handlers - we skip the first nofitication because - // we raise change for the whole instance. + // we raise change for the whole instance. this.addPropertyChangeHandler(span); } }