ampersand-dom-bindings
Advanced tools
Comparing version 3.1.1 to 3.1.2
var Store = require('key-tree-store'); | ||
var isArray = require('is-array'); | ||
var dom = require('ampersand-dom'); | ||
@@ -38,3 +37,3 @@ var matchesSelector = require('matches-selector'); | ||
function getMatches(el, selector, func) { | ||
function getMatches(el, selector) { | ||
if (selector === '') return [el]; | ||
@@ -52,3 +51,2 @@ var matches = []; | ||
var type = binding.type || 'text'; | ||
var hasSelector = true; | ||
var selector = (function () { | ||
@@ -58,3 +56,3 @@ if (typeof binding.selector === 'string') { | ||
} else if (binding.hook) { | ||
return '[data-hook="' + binding.hook + '"]'; | ||
return '[data-hook~="' + binding.hook + '"]'; | ||
} else { | ||
@@ -61,0 +59,0 @@ return ''; |
{ | ||
"name": "ampersand-dom-bindings", | ||
"description": "Takes binding declarations and returns key-tree-store of functions that can be used to apply those bindings.", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"author": "'Henrik Joreteg' <henrik@andyet.net>", | ||
@@ -17,3 +17,5 @@ "bugs": { | ||
"browserify": "^5.11.0", | ||
"jshint": "^2.5.6", | ||
"phantomjs": "^1.9.7-15", | ||
"precommit-hook": "^1.0.7", | ||
"run-browser": "~1.3.1", | ||
@@ -20,0 +22,0 @@ "tap-spec": "^0.2.0", |
@@ -421,1 +421,19 @@ var test = require('tape'); | ||
// TODO: tests for multiple bindings in one declaration | ||
test('Issue #20, Ensure support for space-separated `data-hook`s', function (t) { | ||
var el = getEl('<span class="thing" data-hook="hello other"></span>'); | ||
var bindings = domBindings({ | ||
'model1': { | ||
type: 'text', | ||
hook: 'other' | ||
} | ||
}); | ||
bindings.run('model1', null, el, 'first'); | ||
t.equal(el.firstChild.textContent, 'first'); | ||
bindings.run('model1', null, el, 'second'); | ||
t.equal(el.firstChild.innerHTML, 'second'); | ||
t.end(); | ||
}); |
29519
8
500
8