X Tutup
Skip to content

Commit 01c3402

Browse files
author
jossonsmith
committed
Fixed bug that *.css path is not correct when #registerCSS is called from
*.z.js (e.g TabFolder.z.js, the normal class path should be TabFolder.js)
1 parent 31c8dff commit 01c3402

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

sources/net.sf.j2s.java.core/src/java/lang/ClassExt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,8 @@ Clazz.registerCSS = function (clazzName, cssText) {
841841
/*
842842
* TODO: Keep eyes open on IE. Maybe IE won't initialize this
843843
* javascript-kind of CSS!
844+
* FIXME: IE7 (or IE6 sp2) does not support this kind of
845+
* CSS loading!
844846
*/
845847
document.createStyleSheet ("javascript:Clazz.cssForIE (\"" + cssID + "\");");
846848
} else {

sources/net.sf.j2s.java.core/src/java/lang/ClassLoader.js

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -387,30 +387,38 @@ ClazzLoader.registerPackages = function (prefix, pkgs) {
387387
ClazzLoader.getClasspathFor = function (clazz, forRoot, ext) {
388388
//error ("check js path : " + clazz);
389389
var path = ClazzLoader.classpathMap["#" + clazz];
390-
if (path != null) {
391-
return path;
392-
}
393-
/*
394-
path = ClazzLoader.classpathMap["@" + clazz]; // package
395-
if (path != null) {
396-
return ClazzLoader.assureBase (path) + clazz.replace (/\./g, "/") + "/";
397-
}
398-
*/
399390
var base = null;
400-
var idx = clazz.lastIndexOf (".");
401-
/*
402-
while (idx != -1) {
403-
var pkg = clazz.substring (0, idx);
404-
base = ClazzLoader.classpathMap["@" + pkg];
405-
if (base != null) {
406-
break;
391+
if (path != null) {
392+
if (!forRoot && ext == null) { // return directly
393+
return path;
394+
} else {
395+
var idx = path.lastIndexOf (clazz.replace (/\./g, "/"));
396+
if (idx != -1) {
397+
base = path.substring (0, idx);
398+
}
399+
}
400+
} else {
401+
/*
402+
path = ClazzLoader.classpathMap["@" + clazz]; // package
403+
if (path != null) {
404+
return ClazzLoader.assureBase (path) + clazz.replace (/\./g, "/") + "/";
405+
}
406+
*/
407+
var idx = clazz.lastIndexOf (".");
408+
/*
409+
while (idx != -1) {
410+
var pkg = clazz.substring (0, idx);
411+
base = ClazzLoader.classpathMap["@" + pkg];
412+
if (base != null) {
413+
break;
414+
}
415+
idx = clazz.lastIndexOf (".", idx - 2);
416+
}
417+
*/
418+
if (idx != -1) {
419+
var pkg = clazz.substring (0, idx);
420+
base = ClazzLoader.classpathMap["@" + pkg];
407421
}
408-
idx = clazz.lastIndexOf (".", idx - 2);
409-
}
410-
*/
411-
if (idx != -1) {
412-
var pkg = clazz.substring (0, idx);
413-
base = ClazzLoader.classpathMap["@" + pkg];
414422
}
415423

416424
base = ClazzLoader.assureBase (base);

0 commit comments

Comments
 (0)
X Tutup