Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A7027189C0 for ; Tue, 16 Jun 2015 16:01:59 +0000 (UTC) Received: (qmail 88203 invoked by uid 500); 16 Jun 2015 16:01:59 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 88180 invoked by uid 500); 16 Jun 2015 16:01:59 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 88171 invoked by uid 99); 16 Jun 2015 16:01:59 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jun 2015 16:01:59 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5A09AE027F; Tue, 16 Jun 2015 16:01:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tony--@apache.org To: commits@cordova.apache.org Message-Id: <89f6ece12d424538ba7e309b49d9238e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cordova-lib git commit: fix CB-9145 prepare can lose data during config munge Date: Tue, 16 Jun 2015 16:01:59 +0000 (UTC) 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 Authored: Tue Jun 9 13:05:10 2015 -0400 Committer: Tony Homer 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(''); + prepare._mergeXml(testXml, dstXml, '', true); + testElements = dstXml.findall('access'); + expect(testElements.length).toEqual(1); + //add an internal whitelist access tag + testXml = et.XML(''); + 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