From a06a5f95dfe315e97f49186a9b71a6eadfb6cf09 Mon Sep 17 00:00:00 2001 From: Fatme Date: Wed, 9 Oct 2019 13:24:46 +0300 Subject: [PATCH] fix: xml parsing when input value is reported as object instead of string (#7916) --- tns-core-modules/ui/builder/builder.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tns-core-modules/ui/builder/builder.ts b/tns-core-modules/ui/builder/builder.ts index d2f65c5b5..369d9aef5 100644 --- a/tns-core-modules/ui/builder/builder.ts +++ b/tns-core-modules/ui/builder/builder.ts @@ -6,7 +6,7 @@ import { ViewEntry } from "../frame"; // Types. import { debug, ScopeError, SourceError, Source } from "../../utils/debug"; import * as xml from "../../xml"; -import { isString, isDefined } from "../../utils/types"; +import { isString, isObject, isDefined } from "../../utils/types"; import { ComponentModule, setPropertyValue, getComponentModule } from "./component-builder"; import { platformNames, device } from "../../platform"; import { profile } from "../../profiling"; @@ -215,6 +215,10 @@ namespace xml2ui { parse(args: xml.ParserEvent); } + interface ParseInputData extends String { + default?: string; + } + export class XmlProducerBase implements XmlProducer { private _next: XmlConsumer; public pipe(next: Next) { @@ -235,7 +239,7 @@ namespace xml2ui { this.error = error || PositionErrorFormat; } - public parse(value: string) { + public parse(value: ParseInputData) { const xmlParser = new xml.XmlParser((args: xml.ParserEvent) => { try { this.next(args); @@ -247,7 +251,9 @@ namespace xml2ui { }, true); if (isString(value)) { - xmlParser.parse(value); + xmlParser.parse(value); + } else if (isObject(value) && isString(value.default)) { + xmlParser.parse(value.default); } } }