mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix: xml parsing when input value is reported as object instead of string (#7916)
This commit is contained in:
@ -6,7 +6,7 @@ import { ViewEntry } from "../frame";
|
|||||||
// Types.
|
// Types.
|
||||||
import { debug, ScopeError, SourceError, Source } from "../../utils/debug";
|
import { debug, ScopeError, SourceError, Source } from "../../utils/debug";
|
||||||
import * as xml from "../../xml";
|
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 { ComponentModule, setPropertyValue, getComponentModule } from "./component-builder";
|
||||||
import { platformNames, device } from "../../platform";
|
import { platformNames, device } from "../../platform";
|
||||||
import { profile } from "../../profiling";
|
import { profile } from "../../profiling";
|
||||||
@ -215,6 +215,10 @@ namespace xml2ui {
|
|||||||
parse(args: xml.ParserEvent);
|
parse(args: xml.ParserEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ParseInputData extends String {
|
||||||
|
default?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class XmlProducerBase implements XmlProducer {
|
export class XmlProducerBase implements XmlProducer {
|
||||||
private _next: XmlConsumer;
|
private _next: XmlConsumer;
|
||||||
public pipe<Next extends XmlConsumer>(next: Next) {
|
public pipe<Next extends XmlConsumer>(next: Next) {
|
||||||
@ -235,7 +239,7 @@ namespace xml2ui {
|
|||||||
this.error = error || PositionErrorFormat;
|
this.error = error || PositionErrorFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public parse(value: string) {
|
public parse(value: ParseInputData) {
|
||||||
const xmlParser = new xml.XmlParser((args: xml.ParserEvent) => {
|
const xmlParser = new xml.XmlParser((args: xml.ParserEvent) => {
|
||||||
try {
|
try {
|
||||||
this.next(args);
|
this.next(args);
|
||||||
@ -247,7 +251,9 @@ namespace xml2ui {
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
if (isString(value)) {
|
if (isString(value)) {
|
||||||
xmlParser.parse(value);
|
xmlParser.parse(<string>value);
|
||||||
|
} else if (isObject(value) && isString(value.default)) {
|
||||||
|
xmlParser.parse(value.default);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user