瀏覽代碼

kernel: .added / .removed take care of hierarchy.

Herbert Vojčík 7 年之前
父節點
當前提交
192b0dedb8
共有 1 個文件被更改,包括 11 次插入3 次删除
  1. 11 3
      support/boot.js

+ 11 - 3
support/boot.js

@@ -266,9 +266,15 @@ define(['require', './brikz', './compatibility'], function (require, Brikz) {
         SmalltalkMetaclass.prototype.meta = true;
 
         SmalltalkClass.prototype.added = function () {
+            addSubclass(this);
             if (st._classAdded) st._classAdded(this);
         };
 
+        SmalltalkClass.prototype.removed = function () {
+            if (st._classRemoved) st._classRemoved(this);
+            removeSubclass(this);
+        };
+
         SmalltalkBehavior.prototype.methodAdded = function (method) {
             if (st._methodAdded) st._methodAdded(method, this);
         };
@@ -401,8 +407,6 @@ define(['require', './brikz', './compatibility'], function (require, Brikz) {
                 }
 
                 theClass = globals[spec.className] = classFactories[type](spec);
-
-                addSubclass(theClass);
             }
 
             classes.addElement(theClass);
@@ -414,9 +418,9 @@ define(['require', './brikz', './compatibility'], function (require, Brikz) {
         this.rawAddClass = rawAddClass;
 
         st.removeClass = function (klass) {
+            klass.removed();
             removeOrganizationElement(klass.pkg, klass);
             classes.removeElement(klass);
-            removeSubclass(klass);
             delete globals[klass.className];
         };
 
@@ -567,6 +571,10 @@ define(['require', './brikz', './compatibility'], function (require, Brikz) {
             if (st._traitAdded) st._traitAdded(this);
         };
 
+        SmalltalkTrait.prototype.removed = function () {
+            if (st._traitRemoved) st._traitRemoved(this);
+        };
+
         SmalltalkTrait.prototype.methodAdded = function (method) {
             if (st._traitMethodAdded) st._traitMethodAdded(method, this);
         };