You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2016/03/29 11:21:44 UTC
cordova-lib git commit: CB-10965 xml helper allows multiple instances
to be merge in config.xml
Repository: cordova-lib
Updated Branches:
refs/heads/master 9f630271d -> 9014dd69f
CB-10965 xml helper allows multiple instances to be merge in config.xml
This closes #417
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/9014dd69
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/9014dd69
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/9014dd69
Branch: refs/heads/master
Commit: 9014dd69f4aedda65de704292f02db92cf02639f
Parents: 9f63027
Author: Carlos Santana <cs...@gmail.com>
Authored: Sat Mar 26 18:53:52 2016 -0400
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Tue Mar 29 12:20:35 2016 +0300
----------------------------------------------------------------------
cordova-common/spec/util/xml-helpers.spec.js | 28 +++++++++++++++++++----
cordova-common/src/util/xml-helpers.js | 2 +-
2 files changed, 25 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9014dd69/cordova-common/spec/util/xml-helpers.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/util/xml-helpers.spec.js b/cordova-common/spec/util/xml-helpers.spec.js
index b0083fd..91128a6 100644
--- a/cordova-common/spec/util/xml-helpers.spec.js
+++ b/cordova-common/spec/util/xml-helpers.spec.js
@@ -195,7 +195,7 @@ describe('xml-helpers', function(){
expect(testElement.text).toEqual('testTEXT');
});
- it('should merge singelton children without clobber', function () {
+ it('should merge singleton children without clobber', function () {
var testXml = et.XML('<widget><author testAttrib="value" href="http://www.nowhere.com">SUPER_AUTHOR</author></widget>');
xml_helpers.mergeXml(testXml, dstXml);
@@ -208,7 +208,17 @@ describe('xml-helpers', function(){
expect(testElements[0].text).toContain('Apache Cordova Team');
});
- it('should clobber singelton children with clobber', function () {
+ it('should merge singleton name without clobber', function () {
+ var testXml = et.XML('<widget><name>SUPER_NAME</name></widget>');
+
+ xml_helpers.mergeXml(testXml, dstXml);
+ var testElements = dstXml.findall('name');
+ expect(testElements).toBeDefined();
+ expect(testElements.length).toEqual(1);
+ expect(testElements[0].text).toContain('Hello Cordova');
+ });
+
+ it('should clobber singleton children with clobber', function () {
var testXml = et.XML('<widget><author testAttrib="value" href="http://www.nowhere.com">SUPER_AUTHOR</author></widget>');
xml_helpers.mergeXml(testXml, dstXml, '', true);
@@ -221,6 +231,16 @@ describe('xml-helpers', function(){
expect(testElements[0].text).toEqual('SUPER_AUTHOR');
});
+ it('should merge singleton name with clobber', function () {
+ var testXml = et.XML('<widget><name>SUPER_NAME</name></widget>');
+
+ xml_helpers.mergeXml(testXml, dstXml, '', true);
+ var testElements = dstXml.findall('name');
+ expect(testElements).toBeDefined();
+ expect(testElements.length).toEqual(1);
+ expect(testElements[0].text).toContain('SUPER_NAME');
+ });
+
it('should append non singelton children', function () {
var testXml = et.XML('<widget><preference num="1"/> <preference num="2"/></widget>');
@@ -267,7 +287,7 @@ describe('xml-helpers', function(){
expect(testElements.length).toEqual(2);
});
-
+
it('should remove duplicate preferences (by name attribute value)', function () {
var testXml = et.XML(
'<?xml version="1.0" encoding="UTF-8"?>\n' +
@@ -288,7 +308,7 @@ describe('xml-helpers', function(){
var testElements = dstXml.findall('preference[@name="Orientation"]');
expect(testElements.length).toEqual(1);
});
-
+
it('should merge preferences, with platform preferences written last', function () {
var testXml = et.XML(
'<?xml version="1.0" encoding="UTF-8"?>\n' +
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/9014dd69/cordova-common/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/util/xml-helpers.js b/cordova-common/src/util/xml-helpers.js
index fc84128..6366af9 100644
--- a/cordova-common/src/util/xml-helpers.js
+++ b/cordova-common/src/util/xml-helpers.js
@@ -194,7 +194,7 @@ function findInsertIdx(children, after) {
}
var BLACKLIST = ['platform', 'feature','plugin','engine'];
-var SINGLETONS = ['content', 'author'];
+var SINGLETONS = ['content', 'author', 'name'];
function mergeXml(src, dest, platform, clobber) {
// Do nothing for blacklisted tags.
if (BLACKLIST.indexOf(src.tag) != -1) return;
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org