mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
feat(xml parser): Only allow angular syntax extensions if configured.
Configure via the public `angularSyntax` property on EasySAXParser and the XmlParser wrapper.
This commit is contained in:
1
js-libs/easysax/easysax.d.ts
vendored
1
js-libs/easysax/easysax.d.ts
vendored
@ -5,6 +5,7 @@ declare module "js-libs/easysax" {
|
|||||||
parse(xml: string): void;
|
parse(xml: string): void;
|
||||||
on(name: string, cb: Function): void;
|
on(name: string, cb: Function): void;
|
||||||
ns(root: string, ns: any): void;
|
ns(root: string, ns: any): void;
|
||||||
|
public angularSyntax: boolean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,7 @@ describe("angular xml parser", () => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
parser.angularSyntax = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
it("parses [property] binding", () => {
|
it("parses [property] binding", () => {
|
||||||
@ -53,7 +54,6 @@ describe("angular xml parser", () => {
|
|||||||
assert.equal(last_attrs['text'], 'Name');
|
assert.equal(last_attrs['text'], 'Name');
|
||||||
});
|
});
|
||||||
|
|
||||||
return
|
|
||||||
it("detects equals without value", () => {
|
it("detects equals without value", () => {
|
||||||
parser.parse("<TextField brokenTag= />");
|
parser.parse("<TextField brokenTag= />");
|
||||||
|
|
||||||
@ -71,4 +71,11 @@ describe("angular xml parser", () => {
|
|||||||
|
|
||||||
assert.isFalse(last_attrs);
|
assert.isFalse(last_attrs);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rejects angular properties if syntax disabled", () => {
|
||||||
|
parser.angularSyntax = false;
|
||||||
|
parser.parse("<TextField [text]='somevalue' />");
|
||||||
|
|
||||||
|
assert.isFalse(last_attrs);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
4
xml/xml.d.ts
vendored
4
xml/xml.d.ts
vendored
@ -86,7 +86,7 @@ declare module "xml" {
|
|||||||
* @param onError The callback to execute when a parser error occurs. The 'error' parameter contains the error.
|
* @param onError The callback to execute when a parser error occurs. The 'error' parameter contains the error.
|
||||||
* @param processNamespaces Specifies whether namespaces should be processed.
|
* @param processNamespaces Specifies whether namespaces should be processed.
|
||||||
*/
|
*/
|
||||||
constructor(onEvent: (event: ParserEvent) => void, onError?: (error: Error) => void, processNamespaces?: boolean);
|
constructor(onEvent: (event: ParserEvent) => void, onError?: (error: Error) => void, processNamespaces?: boolean, angularSyntax?: boolean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the supplied xml string.
|
* Parses the supplied xml string.
|
||||||
@ -94,4 +94,4 @@ declare module "xml" {
|
|||||||
*/
|
*/
|
||||||
parse(xmlString: string): void;
|
parse(xmlString: string): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,6 +148,14 @@ export class XmlParser implements definition.XmlParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get angularSyntax() : boolean {
|
||||||
|
return this._parser.angularSyntax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public set angularSyntax(value: boolean) {
|
||||||
|
this._parser.angularSyntax = value;
|
||||||
|
}
|
||||||
|
|
||||||
public parse(xmlString: string): void {
|
public parse(xmlString: string): void {
|
||||||
if (this._processNamespaces) {
|
if (this._processNamespaces) {
|
||||||
this._namespaceStack = [];
|
this._namespaceStack = [];
|
||||||
|
Reference in New Issue
Block a user