Re: [whatwg] Regarding spec clarification on dispatching click event on disabled form controls

2015-05-08 Thread Anne van Kesteren
On Thu, May 7, 2015 at 12:21 PM, Ramya Vadlamudi ramy...@samsung.com wrote:
 https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled

 A form control that is disabled must prevent any click events that are
 queued on the user interaction task source from being dispatched on the
 element.

 Which means except for click events generated by user interaction through
 mouse or keyboard, all other generated events should be dispatched to
 disabled elements.

Actually, it only says the former (since only those end up on the user
interaction task source). It makes no claims about what should happen
for other events.

 https://html.spec.whatwg.org/multipage/interaction.html#dom-click

 The click() method must run the following steps:

 If the element is a form control that is disabled, abort these steps.

 which means even if DOM click is a generated event it should not be
 dispatched to disabled elements, which looks to be bypassing first spec.

It does not bypass, it's just a different requirement.


 For ex: In javascript if button is a HTMLButtonElement

 button.click();   -  As per spec2 event should not be dispatched, as per
 spec1 event should be dispatched

No, spec1 does not apply here.


 button.dispatchEvent(new Event('click'));  - As per spec1 event should be
 dispatched.

Spec1 does not apply here and neither does spec2. So yes, this should
be dispatched, since there's no evidence to the contrary.


 Attached sample test file for you reference.

You might want to upload that somewhere. It did not get through at
least for me. Your browser results were also mangled in a text/plain
view of your email (which is the only one I got).


-- 
https://annevankesteren.nl/


Re: [whatwg] Regarding spec clarification on dispatching click event on disabled form controls

2015-05-08 Thread Ramya Vadlamudi
 

 

Results of Chrome ( Followed spec1 and spec2)

button.click() - event not dispatched

button.dispatchEvent(new Event('click')); - event is dispatched

 

Results of Internet Explorer

button.click() - event not dispatched

button.dispatchEvent(new Event('click')); - event not dispatched

 

Results of Firefox

button.click() - event not dispatched

button.dispatchEvent(new Event('click')); - event not dispatched

 

 

Is there any specific reason to prevent click events that are queued on the
user interaction task source only?

What should be the behavior of other events like button.dispatchEvent(new
Event('click'))?

From the results we can see IE and Firefox are not dispatching any click
event generated to disabled elements.

Please let me know the correct behavior.

 

 

Sample html code used to test is

 

!DOCTYPE HTML

button disabledClick me!/button

div id=log/div

script

function debug(msg, color) {

  var span = document.createElement(span);

  log.appendChild(span);

  span.innerHTML = msg + 'br /';

  if (color)

span.style.color = color;

}

button = document.querySelector('button');

log = document.getElementById('log');

wasClicked = false;

button.addEventListener('click', function(e) {

 

  wasClicked = true;

  alert('click dispatched');

});

 

button.click();

if (wasClicked)

  debug('Receieved click event on button.click()\n', 'red');

else

  debug('No click event on button.click()\n', 'green');

wasClicked = false;

button.dispatchEvent(new Event('click'));

if (wasClicked)

  debug('Receieved click event on button.dispatchEvent()\n', 'red');

else

  debug('No click event on button.dispatchEvent()\n', 'green');

/script

 

 



Re: [whatwg] Regarding spec clarification on dispatching click event on disabled form controls

2015-05-08 Thread Anne van Kesteren
On Fri, May 8, 2015 at 12:07 PM, Ramya Vadlamudi ramy...@samsung.com wrote:
 Is there any specific reason to prevent click events that are queued on the
 user interaction task source only?

Presumably that's the legacy behavior.


 What should be the behavior of other events like button.dispatchEvent(new
 Event('click'))?

 From the results we can see IE and Firefox are not dispatching any click
 event generated to disabled elements.

 Please let me know the correct behavior.

I would say that both IE and Firefox are wrong. dispatchEvent() should
always work. There's nothing in the dispatchEvent() specification that
says it shouldn't for this case.


-- 
https://annevankesteren.nl/


[whatwg] Regarding spec clarification on dispatching click event on disabled form controls

2015-05-07 Thread Ramya Vadlamudi
Regarding the spec clarification,

 

As per spec1

https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled

A form control that is disabled must prevent any click events that are
queued on the user interaction task source from being dispatched on the
element.

 

Which means except for click events generated by user interaction through
mouse or keyboard, all other generated events should be dispatched to
disabled elements.

 

As per spec2

https://html.spec.whatwg.org/multipage/interaction.html#dom-click

The click() method must run the following steps:

If the element is a form control that is disabled, abort these steps.

 

which means even if DOM click is a generated event it should not be
dispatched to disabled elements, which looks to be bypassing first spec.

 

For ex: In javascript if button is a HTMLButtonElement

button.click();   -  As per spec2 event should not be dispatched, as per
spec1 event should be dispatched

button.dispatchEvent(new Event('click'));  - As per spec1 event should be
dispatched.

 

Results in various browsers

 

 


Function

IE

Firefox

Chrome


button.click()

Event not dispatched

Event not dispatched

Event not dispatched


button.dispatchEvent(new Event('click'));

Event not dispatched

Event not dispatched

Event dispatched

 

 

Can you please clarify what is supposed to be the correct behavior.

Attached sample test file for you reference.

 

Thanks  Regards,

Ramya