* Rename "constructor" property in defineProperty() rathern than in put(),
since this is what Rhino uses to set the property at compile time.
This commit is contained in:
parent
740091f4d8
commit
b80b83ffb3
1 changed files with 18 additions and 5 deletions
|
@ -121,6 +121,24 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
|
||||||
return toString();
|
return toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define a JavaScript property. We override this in order to redirect the
|
||||||
|
* "constructor" property with the scripted constructor function as its value
|
||||||
|
* to "__constructor__"
|
||||||
|
*
|
||||||
|
* @param propertyName the name of the property to define.
|
||||||
|
* @param value the initial value of the property
|
||||||
|
* @param attributes the attributes of the JavaScript property
|
||||||
|
*/ public void defineProperty(String propertyName, Object value, int attributes) {
|
||||||
|
// redirect the scripted constructor to __constructor__,
|
||||||
|
// constructor is set to the native constructor method.
|
||||||
|
if (node == null && "constructor".equals(propertyName) &&
|
||||||
|
value instanceof NativeFunction) {
|
||||||
|
propertyName = "__constructor__";
|
||||||
|
}
|
||||||
|
super.defineProperty(propertyName, value, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the INode wrapped by this HopObject.
|
* Return the INode wrapped by this HopObject.
|
||||||
*
|
*
|
||||||
|
@ -676,11 +694,6 @@ public class HopObject extends ScriptableObject implements Wrapper, PropertyReco
|
||||||
*/
|
*/
|
||||||
public void put(String name, Scriptable start, Object value) {
|
public void put(String name, Scriptable start, Object value) {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
// redirect the scripted constructor to __constructor__,
|
|
||||||
// constructor is set to the native constructor method.
|
|
||||||
if ("constructor".equals(name) && value instanceof NativeFunction) {
|
|
||||||
name = "__constructor__";
|
|
||||||
}
|
|
||||||
// register property for PropertyRecorder interface
|
// register property for PropertyRecorder interface
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
changedProperties.add(name);
|
changedProperties.add(name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue