Closed LixenWraith closed 1 day ago
I have ways around it, but would be nice to have it support this best practice approach. Alternative approaches of using attributes such as id, different "submit-button" class, and data attribute work as workaround.
I understand that this is is causing confusion, but I'm not entirely sure about the solution. The default value of <button type
is "submit", so the HTML minifier is correct in removing it. Instead, I would argue that in JS you want to select all buttons of the submit type, for which a correct selector would be querySelector('button[type="submit"], button:not([type])')
Thanks for the response. I implemented with data attribute that in the end saved few more bytes. I'll keep this behavior in mind in the future use. It is a valid minification though may conflict with some use cases. As long as it remains consistent in the future updates, there's no issue and it's an efficient approach.
Input HTML:
<button type="submit" class="button">Send Message</button>
Current Output:
<button class=button>Send Message</button>
Expected Output:
<button type=submit class=button>Send Message</button>
Causing below to fail:
querySelector('button[type="submit"]')