[CB-11120] Allow short/display name in config.xml This adds support for a "short" display name to be specified as an attribute of the `name` element in config.xml.
This attribute is defined in the W3C Widgets spec, on which config.xml is loosely based: https://www.w3.org/TR/widgets/#the-short-attribute This closes #453 Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/03801c8f Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/03801c8f Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/03801c8f Branch: refs/heads/common-2.0.x Commit: 03801c8fbf8e466c8aaf5781c1454744c86f9708 Parents: a43de24 Author: Darryl Pogue <[email protected]> Authored: Sat Jun 4 20:34:51 2016 -0700 Committer: Steve Gill <[email protected]> Committed: Thu Mar 23 21:49:57 2017 -0700 ---------------------------------------------------------------------- cordova-common/spec/ConfigParser/ConfigParser.spec.js | 13 +++++++++++++ cordova-common/src/ConfigParser/ConfigParser.js | 10 ++++++++++ 2 files changed, 23 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/03801c8f/cordova-common/spec/ConfigParser/ConfigParser.spec.js ---------------------------------------------------------------------- diff --git a/cordova-common/spec/ConfigParser/ConfigParser.spec.js b/cordova-common/spec/ConfigParser/ConfigParser.spec.js index f3e334d..fa49550 100644 --- a/cordova-common/spec/ConfigParser/ConfigParser.spec.js +++ b/cordova-common/spec/ConfigParser/ConfigParser.spec.js @@ -83,7 +83,20 @@ describe('config.xml parser', function () { cfg.setName('this.is.bat.country'); expect(cfg.name()).toEqual('this.is.bat.country'); }); + + describe('short name', function() { + it('should default to the app name', function() { + expect(cfg.shortName()).toEqual('Hello Cordova'); + }); + + it('should allow setting the app short name', function() { + cfg.setShortName('Hi CDV'); + expect(cfg.name()).toEqual('Hello Cordova'); + expect(cfg.shortName()).toEqual('Hi CDV'); + }); + }); }); + describe('preference', function() { it('Test 010 : should return the value of a global preference', function() { expect(cfg.getPreference('fullscreen')).toEqual('true'); http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/03801c8f/cordova-common/src/ConfigParser/ConfigParser.js ---------------------------------------------------------------------- diff --git a/cordova-common/src/ConfigParser/ConfigParser.js b/cordova-common/src/ConfigParser/ConfigParser.js index e477a89..cd718de 100644 --- a/cordova-common/src/ConfigParser/ConfigParser.js +++ b/cordova-common/src/ConfigParser/ConfigParser.js @@ -116,6 +116,16 @@ ConfigParser.prototype = { var el = findOrCreate(this.doc, 'name'); el.text = name; }, + shortName: function() { + return this.doc.find('name').attrib['short'] || this.name(); + }, + setShortName: function(shortname) { + var el = findOrCreate(this.doc, 'name'); + if (!el.text) { + el.text = shortname; + } + el.attrib['short'] = shortname; + }, description: function() { return getNodeTextSafe(this.doc.find('description')); }, --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
