(/*mixins*/)
| 78 | // takes an unlimited number of mixin functions as arguments |
| 79 | // typical api call with 3 mixins: defineComponent(timeline, withTweetCapability, withScrollCapability); |
| 80 | function defineComponent(/*mixins*/) { |
| 81 | // unpacking arguments by hand benchmarked faster |
| 82 | var l = arguments.length; |
| 83 | var mixins = new Array(l); |
| 84 | for (var i = 0; i < l; i++) { |
| 85 | mixins[i] = arguments[i]; |
| 86 | } |
| 87 | |
| 88 | var Component = function() {}; |
| 89 | |
| 90 | Component.toString = Component.prototype.toString = prettyPrintMixins; |
| 91 | if (debug.enabled) { |
| 92 | Component.describe = Component.prototype.describe = Component.toString(); |
| 93 | } |
| 94 | |
| 95 | // 'options' is optional hash to be merged with 'defaults' in the component definition |
| 96 | Component.attachTo = attachTo; |
| 97 | // enables extension of existing "base" Components |
| 98 | Component.mixin = function() { |
| 99 | var newComponent = defineComponent(); //TODO: fix pretty print |
| 100 | var newPrototype = Object.create(Component.prototype); |
| 101 | newPrototype.mixedIn = [].concat(Component.prototype.mixedIn); |
| 102 | newPrototype.defaults = utils.merge(Component.prototype.defaults); |
| 103 | newPrototype.attrDef = Component.prototype.attrDef; |
| 104 | compose.mixin(newPrototype, arguments); |
| 105 | newComponent.prototype = newPrototype; |
| 106 | newComponent.prototype.constructor = newComponent; |
| 107 | return newComponent; |
| 108 | }; |
| 109 | Component.teardownAll = teardownAll; |
| 110 | |
| 111 | // prepend common mixins to supplied list, then mixin all flavors |
| 112 | if (debug.enabled) { |
| 113 | mixins.unshift(withLogging); |
| 114 | } |
| 115 | mixins.unshift(withBase, advice.withAdvice, registry.withRegistration); |
| 116 | compose.mixin(Component.prototype, mixins); |
| 117 | |
| 118 | return Component; |
| 119 | } |
| 120 | |
| 121 | defineComponent.teardownAll = function() { |
| 122 | registry.components.slice().forEach(function(c) { |
no outgoing calls
no test coverage detected