Browse Source

Small but important boot.js fixes.

removeElement uses indexOf to be symmetrical to addElement.
_st(..) uses fast `== null` comparision.
Recompilation of Kernel-Objects fixed (`nil subclass:` misbehaved).
Herbert Vojčík 12 years ago
parent
commit
20b7ce21ce
1 changed files with 5 additions and 9 deletions
  1. 5 9
      js/boot.js

+ 5 - 9
js/boot.js

@@ -55,12 +55,8 @@ Array.prototype.addElement = function(el) {
 };
 
 Array.prototype.removeElement = function(el) {
-    for(var i=0; i<this.length; i++) {
-        if(this[i] == el) {
-            this.splice(i, 1);
-            break;
-        }
-    }
+    var i = this.indexOf(el);
+    if (i !== -1) { this.splice(i, 1); }
 };
 
 
@@ -441,7 +437,8 @@ function Smalltalk() {
 
 	st.addClass = function(className, superclass, iVarNames, pkgName) {
 		var pkg = st.addPackage(pkgName);
-		if(st[className] && st[className].superclass === superclass) {
+        if (superclass == nil) { superclass = null; }
+		if(st[className] && st[className].superclass == superclass) {
 			st[className].superclass = superclass;
 			st[className].iVarNames = iVarNames;
 			st[className].pkg = pkg || st[className].pkg;
@@ -799,8 +796,7 @@ if(this.jQuery) {
  */
 
 var _st = function(o) {
-	if(typeof o === 'undefined') {return nil}
-	if(null === o) {return nil}
+	if(o == null) {return nil}
 	if(o.klass) {return o}
 	return smalltalk.JSObjectProxy._on_(o);
 };