Opened 14 years ago
Closed 13 years ago
#3354 closed defect (fixed)
build 0.9-M2 produces "M2 is not defined" in uncompressed version of dojo.js
Reported by: | guest | Owned by: | James Burke |
---|---|---|---|
Priority: | high | Milestone: | 1.0 |
Component: | General | Version: | 0.9 |
Keywords: | M2 is not defined | Cc: | |
Blocked By: | Blocking: |
Description
Setting:
Using the 0.9-M2 as downloaded from: http://download.dojotoolkit.org/experimental/dojo-0.9M2.tar.gz
Testing in firefox 2.0.0.4 on ubuntu 7.04.
Reproduce:
Any HTML page referring to the script ../js/dojo/dojo.js.uncompressed yields a "M2 is not defined" on line 109.
Issue:
Relevant snippet from that file
106 TODOC: HOW TO DOC THIS? 107 dojo.version = { 108 summary: version number of this instance of dojo. 109 major: 0, minor: 9-M2, patch: 0, flag: "", 110 revision: Number("$Rev: 8123 $".match(/[0-9]+/)[0]), 111 toString: function(){ 112 with(dojo.version){ 113 return major + "." + minor + "." + patch + flag + " (" + revision + ")"; String 114 } 115 } 116 }
shows that M2 is interpreted as a variable in the string for the 'minor' property of dojo.version
Workaround:
This could be avoided by defining the property value on line 109 as a string rather then a number/expression. So manually changing
minor: 9-M2
into
minor: '9-M2'
seems to resolve the issue here and now.
Towards a more fundamental/future-proof resolution:
I'm assuming this version-info is inserted automatically by the release/build system under the 'util' portion of your svn tree. Quickly scanning that I assume the relevant lines inside [util-trunk]/buildscripts/jslib/buildUtil.js are these:
454 Set version number. 455 First, break apart the version string. 456 var verSegments = version.split("."); 457 var majorValue = 0; 458 var minorValue = 0; 459 var patchValue = 0; 460 var flagValue = ""; 461 462 if(verSegments.length > 0 && verSegments[0]){ 463 majorValue = verSegments[0]; 464 } 465 if(verSegments.length > 1 && verSegments[1]){ 466 minorValue = verSegments[1]; 467 } 468 if(verSegments.length > 2 && verSegments[2]){ 469 If the patchValue has a string in it, split 470 it off and store it in the flagValue. 471 var patchSegments = verSegments[2].split(/D/); 472 patchValue = patchSegments[0]; 473 if(patchSegments.length > 1){ 474 flagValue = verSegments[2].substring(patchValue.length, verSegments[2].length); 475 } 476 } 477 if(verSegments.length > 3 && verSegments[3]){ 478 flagValue = verSegments[3]; 479 } 480 481 Do the final version replacement. 482 dojoContents = dojoContents.replace( 483 /major:s*d*,s*minor:s*d*,s*patch:s*d*,s*flag:s*".*?"s*,/g, 484 "major: " + majorValue + ", minor: " + minorValue + ", patch: " + patchValue + ", flag: "" + flag Value + ""," 485 );
My first reflex would be to massage the various major/minor/patchValue variables before insertion, letting them have surrounding quotes when they're not simple numbers.
With something like:
xxValue = makeSafePropertyValue(verSegments[yy]);
where
function makeSafePropertyValue(value) {
if ("" + value == "" + new Number(value))
return value;
return "'" + value + "'";
}
Attachments (1)
Change History (5)
comment:1 Changed 14 years ago by
Changed 14 years ago by
Attachment: | dojo-3354.patch added |
---|
patch for the build-system that parses the version string differently to obtain Major.minor.patch-flag info
comment:2 Changed 14 years ago by
Owner: | changed from anonymous to James Burke |
---|
comment:3 Changed 13 years ago by
Milestone: | → 1.0 |
---|
comment:4 Changed 13 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
More thoughts... Dunno for sure but looking at the 'flagValue' part of the version I get the impression the version string should just be parsed differently. Here is my stab:
var testVersions=["0.0.0", "0.9-M2", "0.9.17.152824-M2.30", "my version" , "0.3.x"];
for (i in testVersions) {
}
function parseVersionString(/*String*/ version) {
}
which yields:
V=0.0.0
V=0.9-M2
V=0.9.17.152824-M2.30
V=my version
V=0.3.x