From c192aba30e99408498df75b9ed431e019df7324b Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Wed, 29 Apr 2015 10:58:16 +0300 Subject: [PATCH] default namespace replaced with regex --- .../xml-declaration/xml-declaration-tests.ts | 28 +++++++++++++++++++ ui/builder/builder.ts | 5 +++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/apps/tests/xml-declaration/xml-declaration-tests.ts b/apps/tests/xml-declaration/xml-declaration-tests.ts index caf964d03..adbc64ebc 100644 --- a/apps/tests/xml-declaration/xml-declaration-tests.ts +++ b/apps/tests/xml-declaration/xml-declaration-tests.ts @@ -203,6 +203,34 @@ export function test_parse_ShouldParseCustomComponentWithoutXmlInListViewTemplat helper.navigate(function () { return p; }); + try { + testAction([p.content, p]); + } + finally { + helper.goBack(); + } +} + +export function test_parse_ShouldParseNestedListViewInListViewTemplate() { + var p = builder.parse(''); + + function testAction(views: Array) { + var ctrl; + + var obj = new observable.Observable(); + obj.set("items", [{ subItems: [1] }]); + obj.set("itemLoading", function (args: listViewModule.ItemEventData) { + ctrl = args.view + }); + p.bindingContext = obj; + + TKUnit.wait(0.2); + + TKUnit.assert(ctrl instanceof listViewModule.ListView, "Expected result: ListView!; Actual result: " + ctrl); + }; + + helper.navigate(function () { return p; }); + try { testAction([p.content, p]); } diff --git a/ui/builder/builder.ts b/ui/builder/builder.ts index 494ee1b43..bebdc1a67 100644 --- a/ui/builder/builder.ts +++ b/ui/builder/builder.ts @@ -154,7 +154,10 @@ function parseInternal(value: string, exports: any): componentBuilder.ComponentM throw new Error("XML parse error: " + e.message); }, true); - xmlParser.parse(value.replace('xmlns="http://www.nativescript.org/tns.xsd"', "").replace("xmlns='http://www.nativescript.org/tns.xsd'", "")); + if (types.isString(value)) { + value = value.replace(/xmlns=("|')http:\/\/www.nativescript.org\/tns.xsd\1/, ""); + xmlParser.parse(value); + } return rootComponentModule; }