Merge branch 'CB-10694'

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

Branch: refs/heads/common-1.1.x
Commit: 4d4fbac273f910e8e868b43100fb2e4092084d96
Parents: cc91656 11d1380
Author: Shazron Abdullah <shaz...@apache.org>
Authored: Wed Mar 16 16:38:28 2016 -0700
Committer: Shazron Abdullah <shaz...@apache.org>
Committed: Wed Mar 16 16:38:28 2016 -0700

----------------------------------------------------------------------
 cordova-common/spec/util/xml-helpers.spec.js | 19 +++++++++++++++++++
 cordova-common/src/util/xml-helpers.js       |  6 +++---
 2 files changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/4d4fbac2/cordova-common/spec/util/xml-helpers.spec.js
----------------------------------------------------------------------
diff --cc cordova-common/spec/util/xml-helpers.spec.js
index 9d714f0,59b760a..2138f5c
--- a/cordova-common/spec/util/xml-helpers.spec.js
+++ b/cordova-common/spec/util/xml-helpers.spec.js
@@@ -268,26 -268,25 +268,45 @@@ describe('xml-helpers', function()
  
          });
          
 +        it('should remove duplicate preferences (by name attribute value)', 
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' +
 +                '    <preference name="Orientation" value="portrait" />\n' +
 +                '    <preference name="Orientation" value="landscape" />\n' +
 +                '    <platform name="ios">\n' +
 +                '        <preference name="Orientation" value="all" />\n' +
 +                '        <preference name="Orientation" value="portrait" 
/>\n' +
 +                '    </platform>\n' +
 +                '</widget>\n'
 +            );
 +            xml_helpers.mergeXml(testXml, dstXml, 'ios');
 +            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' +
+                 '<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/4d4fbac2/cordova-common/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --cc cordova-common/src/util/xml-helpers.js
index 85d9799,487a763..fc84128
--- a/cordova-common/src/util/xml-helpers.js
+++ b/cordova-common/src/util/xml-helpers.js
@@@ -216,12 -219,6 +219,9 @@@ function mergeXml(src, dest, platform, 
          });
      }
  
-     //Handle children
-     src.getchildren().forEach(mergeChild);
-     
 +    //Handle duplicate preference tags (by name attribute)
 +    removeDuplicatePreferences(dest);
 +
      function mergeChild (srcChild) {
          var srcTag = srcChild.tag,
              destChild = new et.Element(srcTag),


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

Reply via email to