mint-metrics / mojito-js-delivery

🧪 Source-controlled JS split testing framework for building and launching A/B tests.
https://mojito.mx/docs/js-delivery-intro
Other
16 stars 30 forks source link

Refactor runRecipe() #38

Closed kingo55 closed 4 years ago

kingo55 commented 4 years ago

@dapperdrop and I think this function could be cleaned up. We don't strictly need to add an empty function during runRecipe do we?:

                this.chosenRecipe = recipe;
                var success = false;

                try
                {
                    // Test level css
                    if (this.options.css)
                    {
                        this.injectCSS(this.options.css);
                    }
                    // Recipe level css
                    if (recipe.css)
                    {
                        this.injectCSS(recipe.css);
                    }
                    // Recipe level js
                    if (recipe.js) 
                    {
                        recipe.js(this);
                    }

                    success = true;
                    this.log("Test Object [" + this.options.name + "][" + this.options.id + "] recipe onChosen [" + recipe.name + "][" + recipe.id + "] run.");
                }
allmywant commented 4 years ago

@kingo55 Yes, this looks better.