Skip to content

Commit

Permalink
CB-13979: More consistency for config.xml lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
dpogue committed May 18, 2018
1 parent a452993 commit c700a5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
1 change: 1 addition & 0 deletions spec/fixtures/test-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
14 changes: 5 additions & 9 deletions src/ConfigParser/ConfigParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand All @@ -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);
});
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit c700a5d

Please sign in to comment.