From 2b366b5f78548ccdda4b05c567db9c0065999a19 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Tue, 6 Sep 2016 10:06:28 -0400 Subject: [PATCH] Fix access field --- modules/ui/fields/access.js | 13 ++++++++----- test/spec/ui/fields/access.js | 10 +++++----- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/ui/fields/access.js b/modules/ui/fields/access.js index 2ff4fe75e..fe4f8d26a 100644 --- a/modules/ui/fields/access.js +++ b/modules/ui/fields/access.js @@ -12,9 +12,10 @@ export function access(field) { var wrap = selection.selectAll('.preset-input-wrap') .data([0]); - wrap.enter().append('div') - .attr('class', 'cf preset-input-wrap') - .append('ul'); + var divEnter = wrap.enter().append('div') + .attr('class', 'cf preset-input-wrap'); + divEnter.append('ul') + wrap = wrap.merge(divEnter); items = wrap.select('ul').selectAll('li') .data(field.keys); @@ -41,6 +42,8 @@ export function access(field) { .data(access.options(d))); }); + items = items.merge(enter); + // Update wrap.selectAll('.preset-input-access') @@ -184,8 +187,8 @@ export function access(field) { return tags.access ? tags.access : field.placeholder(); }); - // items.selectAll('#preset-input-access-access') - // .attr('placeholder', 'yes'); + items.selectAll('#preset-input-access-access') + .attr('placeholder', 'yes'); _.forEach(placeholders[tags.highway], function(v, k) { items.selectAll('#preset-input-access-' + k) diff --git a/test/spec/ui/fields/access.js b/test/spec/ui/fields/access.js index 3226f7c91..86b72affd 100644 --- a/test/spec/ui/fields/access.js +++ b/test/spec/ui/fields/access.js @@ -9,11 +9,11 @@ describe('access', function() { it('creates inputs for a variety of modes of access', function() { var access = iD.ui.fields.access(field); selection.call(access); - expect(selection.selectAll('.preset-access-access')[0].length).to.equal(1); - expect(selection.selectAll('.preset-access-foot')[0].length).to.equal(1); - expect(selection.selectAll('.preset-access-motor_vehicle')[0].length).to.equal(1); - expect(selection.selectAll('.preset-access-bicycle')[0].length).to.equal(1); - expect(selection.selectAll('.preset-access-horse')[0].length).to.equal(1); + expect(selection.selectAll('.preset-access-access').size()).to.equal(1); + expect(selection.selectAll('.preset-access-foot').size()).to.equal(1); + expect(selection.selectAll('.preset-access-motor_vehicle').size()).to.equal(1); + expect(selection.selectAll('.preset-access-bicycle').size()).to.equal(1); + expect(selection.selectAll('.preset-access-horse').size()).to.equal(1); }); it('does not include "yes", "designated", "dismount" options for general access (#934), (#2213)', function() {