[ 
https://issues.apache.org/jira/browse/CB-13979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16481111#comment-16481111
 ] 

ASF GitHub Bot commented on CB-13979:
-------------------------------------

dpogue closed pull request #19: CB-13979: More consistency for config.xml 
lookups
URL: https://github.com/apache/cordova-common/pull/19
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/spec/fixtures/test-config.xml b/spec/fixtures/test-config.xml
index 5dd79e6..58928f6 100644
--- a/spec/fixtures/test-config.xml
+++ b/spec/fixtures/test-config.xml
@@ -82,6 +82,7 @@
     <preference name="orientation" value="portrait" />
     <icon id="icon" src="icon.png" />
     <icon height="255" id="logo" src="logo.png" width="255" />
+    <platform name="android"></platform>
     <platform name="android">
         <icon density="mdpi" height="255" src="logo-android.png" width="255" />
         <icon gap:density="mdpi" height="255" src="logo-android-gap.png" 
width="255" />
diff --git a/src/ConfigParser/ConfigParser.js b/src/ConfigParser/ConfigParser.js
index 095ccf2..f6638b7 100644
--- a/src/ConfigParser/ConfigParser.js
+++ b/src/ConfigParser/ConfigParser.js
@@ -161,7 +161,7 @@ ConfigParser.prototype = {
         pref.attrib.value = value;
     },
     getPlatformPreference: function (name, platform) {
-        return findElementAttributeValue(name, 
this.doc.findall('platform[@name=\'' + platform + '\']/preference'));
+        return findElementAttributeValue(name, 
this.doc.findall('./platform[@name="' + platform + '"]/preference'));
     },
     getPreference: function (name, platform) {
 
@@ -185,7 +185,7 @@ ConfigParser.prototype = {
         var ret = [];
         var staticResources = [];
         if (platform) { // platform specific icons
-            this.doc.findall('platform[@name=\'' + platform + '\']/' + 
resourceName).forEach(function (elt) {
+            this.doc.findall('./platform[@name="' + platform + '"]/' + 
resourceName).forEach(function (elt) {
                 elt.platform = platform; // mark as platform specific resource
                 staticResources.push(elt);
             });
@@ -274,7 +274,7 @@ ConfigParser.prototype = {
         var fileResources = [];
 
         if (platform) { // platform specific resources
-            fileResources = this.doc.findall('platform[@name=\'' + platform + 
'\']/resource-file').map(function (tag) {
+            fileResources = this.doc.findall('./platform[@name="' + platform + 
'"]/resource-file').map(function (tag) {
                 return {
                     platform: platform,
                     src: tag.attrib.src,
@@ -539,9 +539,7 @@ ConfigParser.prototype = {
     },
     /* Get all edit-config tags */
     getEditConfigs: function (platform) {
-        var platform_tag = this.doc.find('./platform[@name="' + platform + 
'"]');
-        var platform_edit_configs = platform_tag ? 
platform_tag.findall('edit-config') : [];
-
+        var platform_edit_configs = this.doc.findall('./platform[@name="' + 
platform + '"]/edit-config');
         var edit_configs = 
this.doc.findall('edit-config').concat(platform_edit_configs);
 
         return edit_configs.map(function (tag) {
@@ -559,9 +557,7 @@ ConfigParser.prototype = {
 
     /* Get all config-file tags */
     getConfigFiles: function (platform) {
-        var platform_tag = this.doc.find('./platform[@name="' + platform + 
'"]');
-        var platform_config_files = platform_tag ? 
platform_tag.findall('config-file') : [];
-
+        var platform_config_files = this.doc.findall('./platform[@name="' + 
platform + '"]/config-file');
         var config_files = 
this.doc.findall('config-file').concat(platform_config_files);
 
         return config_files.map(function (tag) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> getEditConfigs() and getConfigFiles() only work for the first <platform> tag
> ----------------------------------------------------------------------------
>
>                 Key: CB-13979
>                 URL: https://issues.apache.org/jira/browse/CB-13979
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-common
>    Affects Versions: Master
>            Reporter: Kevin Christopher Henry
>            Assignee: Darryl Pogue
>            Priority: Minor
>              Labels: pull-request-available
>
> I ran into something strange - my configuration would change based on the 
> ordering of elements in config.xml.
> Looking at the source code, the culprit is getEditConfigs() and 
> getConfigFiles() in ConfigParser.js. Unlike the rest of the code they only 
> look in the first platform tag for config directives:
> {{var platform_tag = this.doc.find('./platform[@name="' + platform + '"]');}}
> {{var platform_edit_configs = platform_tag ? 
> platform_tag.findall('edit-config') : [];}}
> This should probably be something like this instead (untested):
> {{var platform_edit_configs = this.doc.findall('./platform[@name="' + 
> platform + '"]/edit-config');}}
> And similarly for getConfigFiles().



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to