Try ScriptRuntime.toString() in get() to work around unimplemented toString()

in some Rhino native types.
This commit is contained in:
hns 2004-04-01 15:39:06 +00:00
parent fbf6dfe693
commit 750f209035

View file

@ -403,6 +403,17 @@ public class RhinoEngine implements ScriptingEngine {
} else if (prop == Undefined.instance || prop == ScriptableObject.NOT_FOUND) { } else if (prop == Undefined.instance || prop == ScriptableObject.NOT_FOUND) {
return null; return null;
} else { } else {
// not all Rhino types convert to a string as expected
// when calling toString() - try to do better by using
// Rhino's ScriptRuntime.toString(). Note that this
// assumes that people always use this method to get
// a string representation of the object - which is
// currently the case since it's only used in Skin rendering.
try {
return ScriptRuntime.toString(prop);
} catch (Exception x) {
// just return original property object
}
return prop; return prop;
} }
} catch (Exception esx) { } catch (Exception esx) {