cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject cordova-lib git commit: fix CB-9145 prepare can lose data during config munge
Date Tue, 16 Jun 2015 16:01:59 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master c87b48140 -> 8d67d2877


fix CB-9145 prepare can lose data during config munge


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/8d67d287
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/8d67d287
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/8d67d287

Branch: refs/heads/master
Commit: 8d67d28773c60bb5dde6e6b6993c5ba0ddfba8a8
Parents: c87b481
Author: Tony Homer <tony.homer@intel.com>
Authored: Tue Jun 9 13:05:10 2015 -0400
Committer: Tony Homer <tony.homer@intel.com>
Committed: Tue Jun 16 11:49:36 2015 -0400

----------------------------------------------------------------------
 cordova-lib/spec-cordova/prepare.spec.js | 21 +++++++++++++++++++++
 cordova-lib/src/cordova/prepare.js       | 14 +++++++++-----
 2 files changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8d67d287/cordova-lib/spec-cordova/prepare.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/prepare.spec.js b/cordova-lib/spec-cordova/prepare.spec.js
index 87ae5ed..666394c 100644
--- a/cordova-lib/spec-cordova/prepare.spec.js
+++ b/cordova-lib/spec-cordova/prepare.spec.js
@@ -271,4 +271,25 @@ describe('prepare._mergeXml', function () {
         var testElements = dstXml.findall('preference');
         expect(testElements.length).toEqual(2);
     });
+
+    it('should not skip partial duplicate non singelton children', function () {
+        //remove access tags from dstXML
+        var testElements = dstXml.findall('access');
+        for(var i = 0; i < testElements.length; i++) {
+            dstXml.remove(testElements[i]);
+        }
+        testElements = dstXml.findall('access');
+        expect(testElements.length).toEqual(0);
+        //add an external whitelist access tag
+        var testXml = et.XML('<widget><access origin="*" launch-external="yes"/></widget>');
+        prepare._mergeXml(testXml, dstXml, '', true);
+        testElements = dstXml.findall('access');
+        expect(testElements.length).toEqual(1);
+        //add an internal whitelist access tag
+        testXml = et.XML('<widget><access origin="*"/></widget>');
+        prepare._mergeXml(testXml, dstXml, '', true);
+        testElements = dstXml.findall('access');
+        expect(testElements.length).toEqual(2);
+
+    });    
 });

http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/8d67d287/cordova-lib/src/cordova/prepare.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/prepare.js b/cordova-lib/src/cordova/prepare.js
index 7dfcb87..adbf1c6 100644
--- a/cordova-lib/src/cordova/prepare.js
+++ b/cordova-lib/src/cordova/prepare.js
@@ -181,11 +181,15 @@ function mergeXml(src, dest, platform, clobber) {
                 Object.getOwnPropertyNames(srcChild.attrib).forEach(function (attribute)
{
                     query += '[@' + attribute + '="' + srcChild.attrib[attribute] + '"]';
                 });
-                foundChild = dest.find(query);
-                if (foundChild && textMatch(srcChild, foundChild)) {
-                    destChild = foundChild;
-                    dest.remove(destChild);
-                    shouldMerge = false;
+                var foundChildren = dest.findall(query);
+                for(var i = 0; i < foundChildren.length; i++) {
+                    foundChild = foundChildren[i];
+                    if (foundChild && textMatch(srcChild, foundChild) &&
(Object.keys(srcChild.attrib).length==Object.keys(foundChild.attrib).length)) {
+                        destChild = foundChild;
+                        dest.remove(destChild);
+                        shouldMerge = false;
+                        break;
+                    }
                 }
             }
 


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


Mime
View raw message