Fix xml-helpers issue by adding close tag
diff --git a/spec/fixtures/test-config0.xml b/spec/fixtures/test-config0.xml
new file mode 100644
index 0000000..bfdbb5a
--- /dev/null
+++ b/spec/fixtures/test-config0.xml
@@ -0,0 +1,12 @@
+<?xml version='1.0' encoding='utf-8'?>
+<widget android-packageName="io.cordova.hellocordova.android" id="io.cordova.hellocordova" ios-CFBundleIdentifier="io.cordova.hellocordova.ios" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+ <name>Hello Cordova</name>
+ <description>
+ A sample Apache Cordova application that responds to the deviceready event.
+ </description>
+ <author email="dev@cordova.apache.org" href="http://cordova.io">
+ Apache Cordova Team
+ </author>
+ <content src="index.html" />
+ <access origin="*" />
+</widget>
diff --git a/spec/util/xml-helpers.spec.js b/spec/util/xml-helpers.spec.js
index f4d5fbc..e117139 100644
--- a/spec/util/xml-helpers.spec.js
+++ b/spec/util/xml-helpers.spec.js
@@ -209,6 +209,12 @@
xml_helpers.graftXML(config_xml, children, '/*');
expect(config_xml.findall('access').length).toEqual(3);
});
+ it('Test 020-1 : should create parent', function () {
+ var config_xml0 = xml_helpers.parseElementtreeSync(path.join(__dirname, '../fixtures/test-config0.xml'));
+ var children = plugin_xml.find('platform[@name="ios"]/config-file').getchildren();
+ xml_helpers.graftXML(config_xml0, children, '/widget/plugins');
+ expect(config_xml0.find('plugins').getchildren().length).toEqual(1);
+ });
});
describe('graftXMLMerge', function () {
diff --git a/src/util/xml-helpers.js b/src/util/xml-helpers.js
index acb610b..df51583 100644
--- a/src/util/xml-helpers.js
+++ b/src/util/xml-helpers.js
@@ -61,7 +61,7 @@
if (!parent) {
// Try to create the parent recursively if necessary
try {
- var parentToCreate = et.XML('<' + path.basename(selector) + '>');
+ var parentToCreate = et.XML('<' + path.basename(selector) + '/>');
var parentSelector = path.dirname(selector);
this.graftXML(doc, [parentToCreate], parentSelector);