Skip to content

Commit

Permalink
fix: xml parsing when input value is reported as object instead of st…
Browse files Browse the repository at this point in the history
…ring (#7916)
  • Loading branch information
Fatme authored and manoldonev committed Oct 9, 2019
1 parent 76ee9e8 commit a06a5f9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions tns-core-modules/ui/builder/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 extends XmlConsumer>(next: Next) {
Expand All @@ -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);
Expand All @@ -247,7 +251,9 @@ namespace xml2ui {
}, true);

if (isString(value)) {
xmlParser.parse(value);
xmlParser.parse(<string>value);
} else if (isObject(value) && isString(value.default)) {
xmlParser.parse(value.default);
}
}
}
Expand Down

0 comments on commit a06a5f9

Please sign in to comment.