Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix ConfigParser.getPreference error + tests #138

Closed
wants to merge 1 commit into from

2 participants

@alFReD-NSH

Was getting the following error:

ReferenceError: a is not defined
    at Object.ConfigParser.getPreference
        (/home/alfred/repos/cordova-cli/src/ConfigParser.js:88:23)
@alFReD-NSH alFReD-NSH Fix ConfigParser.getPreference error + tests
Was getting the following error:

    ReferenceError: a is not defined
        at Object.ConfigParser.getPreference
            (/home/alfred/repos/cordova-cli/src/ConfigParser.js:88:23)
1880ebb
@agrieve

Thanks for the fix! I've merged it in.

@asfgit asfgit closed this pull request from a commit
@alFReD-NSH alFReD-NSH Fix ConfigParser.getPreference error + tests
Was getting the following error:

    ReferenceError: a is not defined
        at Object.ConfigParser.getPreference
            (/home/alfred/repos/cordova-cli/src/ConfigParser.js:88:23)

github: close #138
3f448d9
@asfgit asfgit closed this in 3f448d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 12, 2014
  1. @alFReD-NSH

    Fix ConfigParser.getPreference error + tests

    alFReD-NSH authored
    Was getting the following error:
    
        ReferenceError: a is not defined
            at Object.ConfigParser.getPreference
                (/home/alfred/repos/cordova-cli/src/ConfigParser.js:88:23)
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 4 deletions.
  1. +8 −0 spec/ConfigParser.spec.js
  2. +4 −4 src/ConfigParser.js
View
8 spec/ConfigParser.spec.js
@@ -72,5 +72,13 @@ describe('config.xml parser', function () {
expect(cfg.name()).toEqual('this.is.bat.country');
});
});
+ describe('preference', function() {
+ it('should get value of existing preference', function() {
+ expect(cfg.getPreference('fullscreen')).toEqual('true');
+ });
+ it('should get undefined as non existing preference', function() {
+ expect(cfg.getPreference('zimzooo!')).toEqual(undefined);
+ });
+ });
});
});
View
8 src/ConfigParser.js
@@ -82,12 +82,12 @@ ConfigParser.prototype = {
getPreference: function(name) {
var preferences = this.doc.findall('preference');
var ret = null;
- for (var i = 0, ii = preferences.length; i < ii; ++i) {
+ preferences.forEach(function (preference) {
// Take the last one that matches.
- if (preferences[i].attrib.name.toLowerCase() === name) {
- ret = a.attrib.value;
+ if (preference.attrib.name.toLowerCase() === name) {
+ ret = preference.attrib.value;
}
- }
+ });
return ret;
},
write:function() {
Something went wrong with that request. Please try again.