Optimize label hover

Add entity IDs to the element class list, so that specific
elements can be selected by ID rather than needing `filter`.
This commit is contained in:
John Firebaugh
2013-05-11 13:12:07 -07:00
parent 578224bd63
commit a53d5cbb44
3 changed files with 20 additions and 27 deletions
+4 -2
View File
@@ -32,14 +32,16 @@ describe("iD.behavior.Hover", function() {
describe("mouseover", function () {
it("adds the .hover class to all elements to which the same datum is bound", function () {
var a = {id: 'a', type: 'node'},
b = {id: 'b', type: 'node'};
container.selectAll('span')
.data([{id: 'a'}, {id: 'b'}, {id: 'a'}, {id: 'b'}])
.data([a, b, a, b])
.enter().append('span').attr('class', function(d) { return d.id; });
container.call(iD.behavior.Hover());
container.selectAll('.a').trigger('mouseover');
expect(container.selectAll('.a.hover')[0]).to.have.length(2);
expect(container.selectAll('.b.hover')[0]).to.have.length(0);
});