diff --git a/CHANGELOG.md b/CHANGELOG.md index 93de5b1..958083f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog +### 1.1.2 (2016-07-09) +- Fix: disallow re-use of bindings, it doesn't work anyways. + + ### 1.1.1 (2016-07-05) - Fix: error messaging in feature detection. diff --git a/lib/index.js b/lib/index.js index bd1f65e..7b0c5e6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -52,6 +52,9 @@ function simulacra (obj, def) { if (!isArray(def)) throw new TypeError('Second argument must be an array.') + if (isProcessedKey in def) + throw new Error('Can not re-use binding.') + if (typeof def[0] === 'string') { query = def[0] def[0] = document.querySelector(query) @@ -188,6 +191,7 @@ function featureCheck (globalScope) { // ECMAScript features. [ Object, 'defineProperty' ], [ Object, 'freeze' ], + [ Object, 'isFrozen' ], [ WeakMap ], // DOM features. diff --git a/package.json b/package.json index bcf1e2d..e9b1edf 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "simulacra", "description": "One-way data binding for web applications.", - "version": "1.1.1", + "version": "1.1.2", "license": "MIT", "author": { "email": "0x8890@airmail.cc", @@ -33,11 +33,11 @@ "browserify-istanbul": "^2.0.0", "cssnano": "^3.7.1", "domino": "^1.0.25", - "eslint": "^3.0.0", + "eslint": "^3.0.1", "eslint-config-boss": "^1.0.4", "fs-extra": "^0.30.0", "highlight.js": "^9.5.0", - "html-minifier": "^2.1.7", + "html-minifier": "^3.0.1", "istanbul": "^0.4.4", "marked": "^0.3.5", "mkdirp": "^0.5.1", diff --git a/test/index.js b/test/index.js index 8e6dcd2..0741654 100644 --- a/test/index.js +++ b/test/index.js @@ -3,6 +3,8 @@ var tapdance = require('tapdance') var comment = tapdance.comment var ok = tapdance.ok +var pass = tapdance.pass +var fail = tapdance.fail var run = tapdance.run var simulacra = require('../lib') @@ -129,12 +131,14 @@ run(function () { ok(outlet.querySelector('.size').textContent === 'XXL', 'continues to work after error') - comment('test rebinding') - outlet.innerHTML = '' - outlet.appendChild(simulacra({ - name: 'babby' - }, bindings)) - ok(outlet.textContent === 'babby!', 'rebinding works') + comment('rebinding should fail') + try { + simulacra({}, bindings) + fail('should have failed') + } + catch (error) { + pass('rebinding does not work') + } })