diff --git a/packages/metal-dom/src/dom.js b/packages/metal-dom/src/dom.js index 14578bbc..6ed0a565 100644 --- a/packages/metal-dom/src/dom.js +++ b/packages/metal-dom/src/dom.js @@ -265,7 +265,7 @@ class dom { var matchesSelector = 'button, input, select, textarea, fieldset'; if (eventName === 'click') { - while (currElement && currElement.tagName !== 'LEGEND') { + while (currElement) { if (currElement.disabled && dom.match(currElement, matchesSelector)) { isAble = false; break; diff --git a/packages/metal-dom/test/dom.js b/packages/metal-dom/test/dom.js index 8e531f75..880bf349 100644 --- a/packages/metal-dom/test/dom.js +++ b/packages/metal-dom/test/dom.js @@ -695,78 +695,6 @@ describe('dom', function() { assert.strictEqual(0, listener3.callCount); assert.strictEqual(0, listener4.callCount); }); - - it('it should trigger delegate click event on elements wrapped by a "legend" tag and with disabled parent', function() { - var fieldset = document.createElement('fieldset'); - var legend = document.createElement('legend'); - fieldset.disabled = true; - fieldset.appendChild(legend); - document.body.appendChild(fieldset); - - var input = document.createElement('input'); - var select = document.createElement('select'); - var button = document.createElement('button'); - var textarea = document.createElement('textarea'); - legend.appendChild(input); - legend.appendChild(select); - legend.appendChild(button); - legend.appendChild(textarea); - - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); - var listener4 = sinon.stub(); - - dom.delegate(fieldset, 'click', input, listener1); - dom.delegate(fieldset, 'click', select, listener2); - dom.delegate(fieldset, 'click', button, listener3); - dom.delegate(fieldset, 'click', textarea, listener4); - - dom.triggerEvent(input, 'click'); - dom.triggerEvent(select, 'click'); - dom.triggerEvent(button, 'click'); - dom.triggerEvent(textarea, 'click'); - assert.strictEqual(1, listener1.callCount); - assert.strictEqual(1, listener2.callCount); - assert.strictEqual(1, listener3.callCount); - assert.strictEqual(1, listener4.callCount); - }); - - it('should not trigger delegate click event to an element which its valid parent is disabled even it is wrapped by another element different of legend', function() { - var fieldset = document.createElement('fieldset'); - var wrapper = document.createElement('div'); - fieldset.disabled = true; - fieldset.appendChild(wrapper); - document.body.appendChild(fieldset); - - var input = document.createElement('input'); - var select = document.createElement('select'); - var button = document.createElement('button'); - var textarea = document.createElement('textarea'); - wrapper.appendChild(input); - wrapper.appendChild(select); - wrapper.appendChild(button); - wrapper.appendChild(textarea); - - var listener1 = sinon.stub(); - var listener2 = sinon.stub(); - var listener3 = sinon.stub(); - var listener4 = sinon.stub(); - - dom.delegate(fieldset, 'click', input, listener1); - dom.delegate(fieldset, 'click', select, listener2); - dom.delegate(fieldset, 'click', button, listener3); - dom.delegate(fieldset, 'click', textarea, listener4); - - dom.triggerEvent(input, 'click'); - dom.triggerEvent(select, 'click'); - dom.triggerEvent(button, 'click'); - dom.triggerEvent(textarea, 'click'); - assert.strictEqual(0, listener1.callCount); - assert.strictEqual(0, listener2.callCount); - assert.strictEqual(0, listener3.callCount); - assert.strictEqual(0, listener4.callCount); - }); }); describe('without selector', function() {