Skip to content

Commit a06a5f9

Browse files
Fatmemanoldonev
authored andcommitted
fix: xml parsing when input value is reported as object instead of string (#7916)
1 parent 76ee9e8 commit a06a5f9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎tns-core-modules/ui/builder/builder.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ViewEntry } from "../frame";
66
// Types.
77
import { debug, ScopeError, SourceError, Source } from "../../utils/debug";
88
import * as xml from "../../xml";
9-
import { isString, isDefined } from "../../utils/types";
9+
import { isString, isObject, isDefined } from "../../utils/types";
1010
import { ComponentModule, setPropertyValue, getComponentModule } from "./component-builder";
1111
import { platformNames, device } from "../../platform";
1212
import { profile } from "../../profiling";
@@ -215,6 +215,10 @@ namespace xml2ui {
215215
parse(args: xml.ParserEvent);
216216
}
217217

218+
interface ParseInputData extends String {
219+
default?: string;
220+
}
221+
218222
export class XmlProducerBase implements XmlProducer {
219223
private _next: XmlConsumer;
220224
public pipe<Next extends XmlConsumer>(next: Next) {
@@ -235,7 +239,7 @@ namespace xml2ui {
235239
this.error = error || PositionErrorFormat;
236240
}
237241

238-
public parse(value: string) {
242+
public parse(value: ParseInputData) {
239243
const xmlParser = new xml.XmlParser((args: xml.ParserEvent) => {
240244
try {
241245
this.next(args);
@@ -247,7 +251,9 @@ namespace xml2ui {
247251
}, true);
248252

249253
if (isString(value)) {
250-
xmlParser.parse(value);
254+
xmlParser.parse(<string>value);
255+
} else if (isObject(value) && isString(value.default)) {
256+
xmlParser.parse(value.default);
251257
}
252258
}
253259
}

0 commit comments

Comments
 (0)