diff options
author | Wilson Page <wilsonpage@me.com> | 2016-01-05 17:18:23 +0000 |
---|---|---|
committer | Wilson Page <wilsonpage@me.com> | 2016-01-05 17:18:23 +0000 |
commit | 643469a572934cafb068163638be001eebfe767c (patch) | |
tree | 15a7c0ef16452549668be91a3f46dfde3204acaa /fastdom.js | |
parent | bd0aa0e1e18f4091a8fe5196e94feaed34e26b36 (diff) | |
download | fastdom-origin/73-object-assign.zip fastdom-origin/73-object-assign.tar.gz fastdom-origin/73-object-assign.tar.bz2 |
Replaced Object.assign() with custom mixin()origin/73-object-assign
Diffstat (limited to 'fastdom.js')
-rw-r--r-- | fastdom.js | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -106,9 +106,8 @@ FastDom.prototype = { * @example * * var myFastdom = fastdom.extend({ - * // called on creation * initialize: function() { - * + * // runs on creation * }, * * // override a method @@ -130,7 +129,7 @@ FastDom.prototype = { if (typeof props != 'object') throw new Error('expected object'); var child = Object.create(this); - Object.assign(child, props); + mixin(child, props); child.fastdom = this; // run optional creation hook @@ -151,7 +150,6 @@ FastDom.prototype = { * * @private */ - function scheduleFlush(fastdom) { if (!fastdom.scheduled) { fastdom.scheduled = true; @@ -203,7 +201,6 @@ function flush(fastdom) { * * @private */ - function runTasks(tasks) { debug('run tasks'); var task; while (task = tasks.shift()) task.fn.call(task.ctx); @@ -221,6 +218,19 @@ function remove(array, item) { return !!~index && !!array.splice(index, 1); } +/** + * Mixin own properties of source + * object into the target. + * + * @param {Object} target + * @param {Object} source + */ +function mixin(target, source) { + for (var key in source) { + if (source.hasOwnProperty(key)) target[key] = source[key]; + } +} + // There should never be more than // one instance of `FastDom` in an app var exports = win.fastdom = (win.fastdom || new FastDom()); // jshint ignore:line |