zombie icon indicating copy to clipboard operation
zombie copied to clipboard

pressButton on <button type="button"> incorrectly submits the form

Open arturog opened this issue 6 years ago • 3 comments

arturog avatar Feb 20 '19 13:02 arturog

When pressing a <button type="button"> contained within a <form>, the form is incorrectly submitted. <button type="button"> should not by default submit the form as per specs.

(I believe this is a jsdom problem...)

arturog avatar Feb 20 '19 13:02 arturog

OK, I think the problem is in Zombie:

  1. when pressButton is called, the event is correctly dispatched https://github.com/assaf/zombie/blob/bbcd5a6b4c31ecc2bd697d48c0e56086ab7d0b8a/src/index.js#L360-L366

  2. But after dispatching the event, we call _click, which submits the form always. https://github.com/assaf/zombie/blob/bbcd5a6b4c31ecc2bd697d48c0e56086ab7d0b8a/src/dom/forms.js#L241-L250

I think the correct place to disable the submission would be the _click function. @assaf if you're happy to put the check in _click I can send a small patch.

arturog avatar Feb 28 '19 16:02 arturog

Yes, please send a path

assaf avatar Mar 18 '19 00:03 assaf