Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium jQuery

New issue 1810 by [email protected]: Domado elements behave spuriously in response to jQuery click()
http://code.google.com/p/google-caja/issues/detail?id=1810

Given the following example code:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>

<p id="a">clickme A</p>
<p id="b">clickme B</p>
<p id="c">clickme C</p>

<p id="d">clickme D</p>
<p id="e">clickme E</p>
<p id="f">clickme F</p>

<script>
  var s = '';
  $('#a')[0].onclick = function() {
    s += 'clicked A';
  };
  $('#b')[0].addEventListener('click', function() {
    s += 'clicked B';
  });
  $('#c').on('click', function() {
    s += 'clicked C';
  });
  $('#a').click();
  $('#b').click();
  $('#c').click();
  alert(s);

  $('#d')[0].onclick = function() {
    alert('clicked D');
  };
  $('#e')[0].addEventListener('click', function() {
    alert('clicked E');
  });
  $('#f').on('click', function() {
    alert('clicked F');
  });
</script>

It initially alerts only "clicked C", meaning that as a result of the programmatic jQuery click(), only the element on which the click handler was registered using jQuery's own $().on(...) actually received the click event. Elements A and B did not get the event.

When I manually click on any of elements D, E or F, the relevant alert is seen, which means that the actual user click event *was* seen by the event handler.

This seems confusing and requires more study. Why are click events being delivered anyway as a result of the jQuery $().click(), when Domado is not processing a user action? And why is that being done only for elements A and B, but not for C? Does jQuery circumvent our "is processing user action" logic, and if so, how?

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to