cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject [1/2] cordova-windows git commit: CB-10622 Upgrade cordova-common to work with 'target'-defined icons
Date Fri, 01 Apr 2016 11:14:09 GMT
Repository: cordova-windows
Updated Branches:
  refs/heads/4.3.x 7f9b79c58 -> 8224a6ea3


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/8224a6ea/node_modules/cordova-common/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --git a/node_modules/cordova-common/src/util/xml-helpers.js b/node_modules/cordova-common/src/util/xml-helpers.js
index 8b02989..fc84128 100644
--- a/node_modules/cordova-common/src/util/xml-helpers.js
+++ b/node_modules/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,8 +219,8 @@ function mergeXml(src, dest, platform, clobber) {
         });
     }
 
-    //Handle children
-    src.getchildren().forEach(mergeChild);
+    //Handle duplicate preference tags (by name attribute)
+    removeDuplicatePreferences(dest);
 
     function mergeChild (srcChild) {
         var srcTag = srcChild.tag,
@@ -254,6 +257,26 @@ function mergeXml(src, dest, platform, clobber) {
             dest.append(destChild);
         }
     }
+    
+    function removeDuplicatePreferences(xml) {
+        // reduce preference tags to a hashtable to remove dupes
+        var prefHash = xml.findall('preference[@name][@value]').reduce(function(previousValue,
currentValue) {
+            previousValue[ currentValue.attrib.name ] = currentValue.attrib.value;
+            return previousValue;
+        }, {});
+        
+        // remove all preferences
+        xml.findall('preference[@name][@value]').forEach(function(pref) {
+            xml.remove(pref);
+        });
+        
+        // write new preferences
+        Object.keys(prefHash).forEach(function(key, index) {
+            var element = et.SubElement(xml, 'preference');
+            element.set('name', key);
+            element.set('value', this[key]);
+        }, prefHash);
+    }
 }
 
 // Expose for testing.

http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/8224a6ea/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index bd2c860..aa3e5e3 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
         "jshint": "jshint bin && jshint template && jshint spec"
     },
     "dependencies": {
-        "cordova-common": "^1.0.0",
+        "cordova-common": "^1.1.1",
         "elementtree": "^0.1.6",
         "node-uuid": "^1.4.3",
         "nopt": "^3.0.4",
@@ -48,4 +48,4 @@
     ],
     "author": "Apache Software Foundation",
     "license": "Apache-2.0"
-}
\ No newline at end of file
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message