mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Merge pull request #475 from NativeScript/lower-case-dashed
Support lower-case-dashed component declaration in the XML added
This commit is contained in:
@ -19,6 +19,7 @@ import helper = require("../ui/helper");
|
||||
import viewModule = require("ui/core/view");
|
||||
import platform = require("platform");
|
||||
import gesturesModule = require("ui/gestures");
|
||||
import segmentedBar = require("ui/segmented-bar");
|
||||
|
||||
export function test_load_IsDefined() {
|
||||
TKUnit.assert(types.isFunction(builder.load), "ui/builder should have load method!");
|
||||
@ -322,6 +323,15 @@ export function test_parse_CanBindBackgroundImage() {
|
||||
TKUnit.assert(sw.backgroundImage === expected, "Expected result: " + expected + "; Actual result: " + sw.backgroundImage);
|
||||
};
|
||||
|
||||
export function test_parse_ShouldParseLowerCaseDashedComponentDeclaration() {
|
||||
var p = <page.Page>builder.parse('<page><stack-layout><label text="Label" /><segmented-bar><segmented-bar.items><segmented-bar-item title="test" /></segmented-bar.items></segmented-bar></stack-layout></page>');
|
||||
var ctrl = <stackLayoutModule.StackLayout>p.content;
|
||||
|
||||
TKUnit.assert(ctrl instanceof stackLayoutModule.StackLayout, "Expected result: StackLayout!; Actual result: " + ctrl);
|
||||
TKUnit.assert(ctrl.getChildAt(0) instanceof labelModule.Label, "Expected result: Label!; Actual result: " + ctrl.getChildAt(0));
|
||||
TKUnit.assert(ctrl.getChildAt(1) instanceof segmentedBar.SegmentedBar, "Expected result: Label!; Actual result: " + ctrl.getChildAt(0));
|
||||
};
|
||||
|
||||
export function test_parse_ShouldParseCustomComponentWithoutXml() {
|
||||
var p = <page.Page>builder.parse('<Page xmlns:customControls="xml-declaration/mymodule"><customControls:MyControl /></Page>');
|
||||
var ctrl = p.content;
|
||||
|
@ -35,6 +35,9 @@ export function getComponentModule(elementName: string, namespace: string, attri
|
||||
var instanceModule: Object;
|
||||
var componentModule: definition.ComponentModule;
|
||||
|
||||
// Support lower-case-dashed component declaration in the XML (https://github.com/NativeScript/NativeScript/issues/309).
|
||||
elementName = elementName.split("-").map(s => { return s[0].toUpperCase() + s.substring(1) }).join("");
|
||||
|
||||
// Get module id.
|
||||
var moduleId = MODULES[elementName] || UI_PATH +
|
||||
(elementName.toLowerCase().indexOf("layout") !== -1 ? "layouts/" : "") +
|
||||
|
Reference in New Issue
Block a user