diff options
author | Wilson Page <wilsonpage@me.com> | 2015-02-13 19:49:50 +0000 |
---|---|---|
committer | Wilson Page <wilsonpage@me.com> | 2016-01-04 12:21:44 +0000 |
commit | 4ade1a6b6b14fcef9686ab9eb03e6e4951b948fc (patch) | |
tree | 1cf3226ef4b51cbd069bc01ca15343f081646657 /src/fastdom-strict.js | |
parent | 6c4958941d2c86cdfa6dc17a8b286399f3f71729 (diff) | |
download | fastdom-origin/v1-beta.zip fastdom-origin/v1-beta.tar.gz fastdom-origin/v1-beta.tar.bz2 |
Diffstat (limited to 'src/fastdom-strict.js')
-rw-r--r-- | src/fastdom-strict.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/fastdom-strict.js b/src/fastdom-strict.js new file mode 100644 index 0000000..86d3f4e --- /dev/null +++ b/src/fastdom-strict.js @@ -0,0 +1,49 @@ +'use strict'; + +var strictdom = require('strictdom'); +var fastdom = require('../fastdom'); + +/** + * Mini logger + * + * @return {Function} + */ +var debug = 0 ? console.log.bind(console, '[fastdom-strict]') : function() {}; + +/** + * Enabled state + * + * @type {Boolean} + */ +var enabled = false; + +window.fastdom = module.exports = fastdom.extend({ + measure: function(task, ctx) { + debug('measure'); + return this.fastdom.measure(function() { + if (!enabled) return task(); + return strictdom.phase('measure', task); + }, ctx); + }, + + mutate: function(task, ctx) { + debug('mutate'); + return this.fastdom.mutate(function() { + if (!enabled) return task(); + return strictdom.phase('mutate', task); + }, ctx); + }, + + strict: function(value) { + if (value) { + enabled = true; + strictdom.enable(); + } else { + enabled = false; + strictdom.disable(); + } + } +}); + +// turn on strict-mode +window.fastdom.strict(true); |