diff --git a/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment-the-fragment.xml b/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment-the-fragment.xml
new file mode 100644
index 000000000..68fa7cae3
--- /dev/null
+++ b/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment-the-fragment.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment.ts b/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment.ts
new file mode 100644
index 000000000..7fc17f985
--- /dev/null
+++ b/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment.ts
@@ -0,0 +1,2 @@
+// Our unit test will set this function and expect it to be set as a handler on a View in the XML.
+export var test: (args: any) => void;
\ No newline at end of file
diff --git a/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment.xml b/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment.xml
new file mode 100644
index 000000000..aad2a0c3c
--- /dev/null
+++ b/apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment.xml
@@ -0,0 +1,4 @@
+
+
+
diff --git a/apps/tests/xml-declaration/xml-declaration-tests.ts b/apps/tests/xml-declaration/xml-declaration-tests.ts
index 1dbaba4df..b88350cbb 100644
--- a/apps/tests/xml-declaration/xml-declaration-tests.ts
+++ b/apps/tests/xml-declaration/xml-declaration-tests.ts
@@ -893,5 +893,31 @@ export function test_EventInTemplate() {
object: childTemplateView
});
+ TKUnit.assert(notified, "Expected the child to raise the test event.");
+}
+
+export function test_EventInCodelessFragment() {
+ var pageCode = require("./template-builder-tests/event-in-codeless-fragment");
+
+ var notified = false;
+ pageCode.test = (args) => {
+ notified = true;
+ }
+
+ var basePath = "xml-declaration/";
+ var message;
+ var page = builder.load(__dirname + "/template-builder-tests/event-in-codeless-fragment.xml", pageCode);
+ TKUnit.assert(view, "Expected the xml to generate a page");
+ var templateView = page.getViewById("template-view");
+ TKUnit.assert(templateView, "Expected the page to have a TemplateView with 'temaplte-view' id.");
+ templateView.parseTemplate();
+ TKUnit.assertEqual(templateView.getChildrenCount(), 1, "Expected TemplateView initially to have 1 child.");
+ var childTemplateView = templateView.getChildAt(0);
+ TKUnit.assert(childTemplateView, "Expected the TemplateView's template to create a child TemplateView.");
+ childTemplateView.notify({
+ eventName: "test",
+ object: childTemplateView
+ });
+
TKUnit.assert(notified, "Expected the child to raise the test event.");
}
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index 1279c1f30..86f098620 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -319,8 +319,9 @@
"apps/tests/xml-declaration/mainPage.ts",
"apps/tests/xml-declaration/mymodule/MyControl.ts",
"apps/tests/xml-declaration/mymodulewithxml/MyControl.ts",
- "apps/tests/xml-declaration/template-builder-tests/event-in-template.ts",
"apps/tests/xml-declaration/template-builder-tests/template-view.ts",
+ "apps/tests/xml-declaration/template-builder-tests/event-in-template.ts",
+ "apps/tests/xml-declaration/template-builder-tests/event-in-codeless-fragment.ts",
"apps/tests/xml-declaration/xml-declaration-tests.ts",
"apps/tests/xml-parser-tests/xml-parser-tests.ts",
"apps/transforms/app.ts",
diff --git a/ui/builder/builder.ts b/ui/builder/builder.ts
index edae02b44..9c0dec3be 100644
--- a/ui/builder/builder.ts
+++ b/ui/builder/builder.ts
@@ -63,7 +63,7 @@ function loadCustomComponent(componentPath: string, componentName?: string, attr
// Custom components with XML
var jsFilePath = fileResolverModule.resolveFileName(fullComponentPathFilePathWithoutExt, "js");
- var subExports;
+ var subExports = context;
if (jsFilePath) {
// Custom components with XML and code
subExports = require(jsFilePath)