You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2016/03/19 01:57:14 UTC
[27/37] cordova-lib git commit: CB-10694 - Platform-specific
configuration preferences don't override global settings
CB-10694 - Platform-specific configuration preferences don't override global settings
Includes jasmine test.
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/11d13805
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/11d13805
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/11d13805
Branch: refs/heads/common-1.1.x
Commit: 11d1380537da46639c6dbbe8d32bcd3fa03e9ad8
Parents: 186eea0
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed Mar 16 10:42:23 2016 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Mar 16 11:18:31 2016 -0700
----------------------------------------------------------------------
cordova-common/spec/util/xml-helpers.spec.js | 21 +++++++++++++++++++++
cordova-common/src/util/xml-helpers.js | 6 +++---
2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/11d13805/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 8cc46ca..59b760a 100644
--- a/cordova-common/spec/util/xml-helpers.spec.js
+++ b/cordova-common/spec/util/xml-helpers.spec.js
@@ -267,5 +267,26 @@ describe('xml-helpers', function(){
expect(testElements.length).toEqual(2);
});
+
+ it('should merge preferences, with platform preferences written last', function () {
+ var testXml = et.XML(
+ '<?xml version="1.0" encoding="UTF-8"?>\n' +
+ '<widget xmlns = "http://www.w3.org/ns/widgets"\n' +
+ ' xmlns:cdv = "http://cordova.apache.org/ns/1.0"\n' +
+ ' id = "io.cordova.hellocordova"\n' +
+ ' version = "0.0.1">\n' +
+ ' <preference name="Orientation" value="default" />\n' +
+ ' <platform name="ios">\n' +
+ ' <preference name="Orientation" value="all" />\n' +
+ ' </platform>\n' +
+ '</widget>\n'
+ );
+ xml_helpers.mergeXml(testXml, dstXml, 'ios');
+ var testElements = dstXml.findall('preference[@name="Orientation"]');
+ expect(testElements.length).toEqual(2);
+ expect(testElements[0].attrib.value).toEqual('default');
+ expect(testElements[1].attrib.value).toEqual('all');
+ });
+
});
});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/11d13805/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 8b02989..487a763 100644
--- a/cordova-common/src/util/xml-helpers.js
+++ b/cordova-common/src/util/xml-helpers.js
@@ -209,6 +209,9 @@ function mergeXml(src, dest, platform, clobber) {
if (src.text && (clobber || !dest.text)) {
dest.text = src.text;
}
+ //Handle children
+ src.getchildren().forEach(mergeChild);
+
//Handle platform
if (platform) {
src.findall('platform[@name="' + platform + '"]').forEach(function (platformElement) {
@@ -216,9 +219,6 @@ function mergeXml(src, dest, platform, clobber) {
});
}
- //Handle children
- src.getchildren().forEach(mergeChild);
-
function mergeChild (srcChild) {
var srcTag = srcChild.tag,
destChild = new et.Element(srcTag),
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org