generators/jelly/templates/javascripts/jelly.js in honkster-jelly-0.8.8 vs generators/jelly/templates/javascripts/jelly.js in honkster-jelly-0.8.9

- old
+ new

@@ -1,10 +1,10 @@ /** * Jelly. a sweet unobtrusive javascript framework * for jQuery and Rails * - * version 0.8.8 + * version 0.8.9 * * Copyright (c) 2009 Pivotal Labs * Licensed under the MIT license. * * * Date: 2009-07-20 9:50:50 (Mon, 20 Jul 2009) @@ -33,26 +33,34 @@ if (this == Jelly) { return Jelly.Observers.attach.apply(this.observers, arguments); } for (var i = 0; i < arguments.length; i++) { var definitionOrComponent = arguments[i]; - var observer; if (definitionOrComponent.component) { var component = Jelly.Observers.evaluateComponent(definitionOrComponent.component); if (component.init) { - observer = component.init.apply(component, definitionOrComponent.arguments) || component; + var initReturnValue = component.init.apply(component, definitionOrComponent.arguments); + if (initReturnValue === false || initReturnValue === null) { + } else { + Jelly.Observers.pushIfObserver.call(this, component.init.apply(component, definitionOrComponent.arguments) || component); + } } else { - observer = component; + Jelly.Observers.pushIfObserver.call(this, component); } } else { - observer = Jelly.Observers.evaluateComponent(definitionOrComponent); + Jelly.Observers.pushIfObserver.call(this, Jelly.Observers.evaluateComponent(definitionOrComponent)); } - this.push(observer); } }, evaluateComponent: function(component) { return (typeof component == "string") ? eval(component) : component; + }, + + pushIfObserver: function(observer) { + if (observer) { + this.push(observer); + } }, notify: function(callbacks) { if (this == Jelly) { return Jelly.Observers.notify.apply(this.observers, arguments);