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
This commit is contained in:
Bundyo (Kamen Bundev)
2019-06-24 11:52:33 +03:00
committed by Manol Donev
parent bcb33c46ab
commit 01c4b8ceb5

View File

@ -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<Span>;
@ -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);
}
}