Browse Source

kernel: Extract trait's propagateMethodChange.

Herby Vojčík 4 years ago
parent
commit
97a0659f5e
1 changed files with 8 additions and 8 deletions
  1. 8 8
      lang/base/kernel-language.js

+ 8 - 8
lang/base/kernel-language.js

@@ -155,19 +155,19 @@ define(['./junk-drawer'], function ($goodies) {
             };
 
             SmalltalkTrait.prototype.methodAdded = function (method) {
-                var self = this;
-                this.traitUsers.forEach(function (each) {
-                    traitMethodChanged(method.selector, method, self, each);
-                });
+                propagateMethodChange(this, method.selector, method);
             };
 
             SmalltalkTrait.prototype.methodRemoved = function (method) {
-                var self = this;
-                this.traitUsers.forEach(function (each) {
-                    traitMethodChanged(method.selector, null, self, each);
-                });
+                propagateMethodChange(this, method.selector, null);
             };
 
+            function propagateMethodChange (trait, selector, method) {
+                trait.traitUsers.forEach(function (each) {
+                    traitMethodChanged(selector, method, trait, each);
+                });
+            }
+
             function traitBuilder (traitName, category) {
                 return {
                     name: traitName,