Opened 8 years ago

Closed 8 years ago

#13386 closed defect (wontfix)

onClick called twice on dojox.mobile.Button when parsed with dojo.parser

Reported by: zhangyp Owned by: Douglas Hays
Priority: high Milestone: 1.7
Component: DojoX Mobile Version: 1.7.0b1
Keywords: Cc: ykami, ccmitchellusa@…
Blocked By: Blocking:

Description

This testcase to show the difference between dojo.parser and dojox.mobile.parser. When using dojo.parser to parse dojox.mobile.Button, the onClick will be called twice, the test cases can be found in attachment. To reproduce the problem, put the test html page in dojox/mobile/tests directory, open the html pages in Chrome and enable the console log. For the button parsed by dojo.parser, the log of click handler of the dojox.mobile.Button will be printed twice while the one parsed by dojox.mobile.parser will only print it once.

The root cause of the problem is that dojo.parser override onClick function in the dijit.form._ButtonMixin which is mixed into dojox.mobile.Button, while dojox.mobile.parser does not do that.

Attachments (2)

testcase.zip (2.0 KB) - added by zhangyp 8 years ago.
parser.doc (69.5 KB) - added by zhangyp 8 years ago.
documentation to describe the details of the root cause

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by zhangyp

Attachment: testcase.zip added

Changed 8 years ago by zhangyp

Attachment: parser.doc added

documentation to describe the details of the root cause

comment:1 Changed 8 years ago by zhangyp

I have uploaded the document parser.doc to describe more details about the root cause of the problem.

comment:2 Changed 8 years ago by Douglas Hays

Component: CoreDojoX Mobile
Milestone: tbd1.7
Owner: set to Douglas Hays
Priority: normalhigh
Status: newassigned

comment:3 Changed 8 years ago by Douglas Hays

Stephen, I think the problem stems from the extra onclick handler in mobile/Button.js. Would you please test the attached patch to see if there are any side-effects (like a missed click event in some scenario)?

comment:4 Changed 8 years ago by Douglas Hays

Resolution: wontfix
Status: assignedclosed

Please ignore the previous comment. mobile.parser does not support functions specified as onclick= in markup but rather have to be specified as data-dojo-props="onClick:function(e){ blah; return false; }"
The onclick= is setting the BUTTON tag's onclick handler which always fires since the tag is not templated and thus is not replaced in the DOM. The problem is that the dojo.parser understands onclick= and additionally sets the widget's onClick method, which gets run after the BUTTON tag's onclick handler runs, and then reruns the handler. Bottom line: specifying data-dojo-props with function parameters will work with either parser. For these testcases to work, the mobile.parser would need to understand function attributes AND the native function attributes that are associated with methods inside widgets would have to be removed from the DOM to prevent native event triggering. Because of this, I think this is a wontfix.

Note: See TracTickets for help on using tickets.