Ver código fonte

kernel: set method's jsSelector lazily in runtime.

Herby Vojčík 6 anos atrás
pai
commit
b148a7469b
2 arquivos alterados com 8 adições e 4 exclusões
  1. 1 2
      support/kernel-fundamentals.js
  2. 7 2
      support/kernel-runtime.js

+ 1 - 2
support/kernel-fundamentals.js

@@ -166,7 +166,7 @@ define(function () {
         st.traitsOrClasses = this.traitsOrClasses = traitsOrClasses;
     }
 
-    MethodsBrik.deps = ["event", "selectors", "root", "selectorConversion"];
+    MethodsBrik.deps = ["event", "selectors", "root"];
     function MethodsBrik (brikz, st) {
         var registerSelector = brikz.selectors.registerSelector;
         var SmalltalkObject = brikz.root.Object;
@@ -186,7 +186,6 @@ define(function () {
             var that = new SmalltalkMethod();
             var selector = spec.selector;
             that.selector = selector;
-            that.jsSelector = st.st2js(selector);
             that.args = spec.args || {};
             that.protocol = spec.protocol;
             that.source = spec.source;

+ 7 - 2
support/kernel-runtime.js

@@ -165,12 +165,17 @@ define(function () {
         }
     }
 
-    RuntimeMethodsBrik.deps = ["event"];
+    RuntimeMethodsBrik.deps = ["event", "selectorConversion"];
     function RuntimeMethodsBrik (brikz, st) {
+        var st2js = brikz.selectorConversion.st2js;
         var emit = brikz.event.emit;
 
         function installMethod (method, klass) {
-            installJSMethod(klass.fn.prototype, method.jsSelector, method.fn);
+            var jsSelector = method.jsSelector;
+            if (!jsSelector) {
+                jsSelector = method.jsSelector = st2js(method.selector);
+            }
+            installJSMethod(klass.fn.prototype, jsSelector, method.fn);
         }
 
         this.installMethod = installMethod;