1
0
Преглед на файлове

Handles JS object properties too

Nicolas Petton преди 13 години
родител
ревизия
c43117b995
променени са 1 файла, в които са добавени 12 реда и са изтрити 9 реда
  1. 12 9
      js/boot.js

+ 12 - 9
js/boot.js

@@ -33,7 +33,6 @@
    |
    ==================================================================== */
 
-
 /* Smalltalk constructors definition */
 
 function SmalltalkObject(){};
@@ -213,20 +212,24 @@ function Smalltalk(){
 	/* Handles JS method calls. Assumes that a single array or single argument was passed from Jtalk.
 	   Example: someJSObject foo: #(1 2 3) -> someJSObject.foo(1,2,3); */
 	var jsSelector = selector.replace(/_/g, '');
-	var jsFunction = receiver[jsSelector];
+	var jsProperty = receiver[jsSelector];
 	var jsArguments;
-	if(receiver.klass === undefined && typeof jsFunction === "function") {
-	    if(args[0] && args[0].constructor === Array) {
-		jsArguments = args[0]
-	    } else {
-		jsArguments = [args[0]]
+	if(receiver.klass === undefined) {
+	    if(typeof jsProperty === "function") {
+		if(args[0] && args[0].constructor === Array) {
+		    jsArguments = args[0]
+		} else {
+		    jsArguments = [args[0]]
+		}
+		return jsProperty.apply(receiver, jsArguments);
+	    } else if(jsProperty !== undefined) {
+		return jsProperty
 	    }
-	    return jsFunction.apply(receiver, jsArguments);
 	}
 
 	/* Handles not understood messages. Also see the Jtalk counter-part 
 	   Object>>doesNotUnderstand: */
-	if(!receiver.klass) {throw(receiver + ' is not a Jtalk object and ' + jsSelector + ' is not a function')}
+	if(!receiver.klass) {throw(receiver + ' is not a Jtalk object and ' + jsSelector + ' is undefined')}
 	
 	return receiver._doesNotUnderstand_(
 	    st.Message._new()