stencil icon indicating copy to clipboard operation
stencil copied to clipboard

Stencil removes type attribute from button

Open BilalAlam173 opened this issue 7 years ago • 4 comments

@stencil/[email protected]

I'm submitting a: [ x] bug report

Current behavior: After updating stencil, The buttons in my component's JSX gets rendered without 'type' attribute, apparently stencil removes the type attribute from the buttons

Expected behavior: It should not remove type attribute

Steps to reproduce: Add a type attribute inside JSX with inline IF condition in a component

Related code:

TSX:
`return (
      <div class="dialog-footer">
        {this.okButtonText ?
          <button class="ui button blue"
                  disabled={false} type={"submit"}>{this.okButtonText}</button> : ""}

        {this.cancelButtonText ?
          <button type={"button"} onClick={() => this.onHide.emit()}
                  class="ui button haze">{this.cancelButtonText}</button> : ""}

      </div>
    );`


AFTER BUILD:
`render() {
        return (h("div", { class: "dialog-footer" }, this.okButtonText ?
            h("button", { class: "ui button blue", disabled: false, type: "submit" }, this.okButtonText) : "", this.cancelButtonText ?
            h("button", { type: "button", onClick: () => this.onHide.emit(), class: "ui button haze" }, this.cancelButtonText) : ""));
    }`

FINAL HTML:
`<div class="dialog-footer"><button class="ui button blue">Save Settings</button></div>`

BilalAlam173 avatar Sep 25 '19 07:09 BilalAlam173

I verified further the attribute only gets removed if the value is "submit", remains intact if value is "button".

BilalAlam173 avatar Sep 25 '19 08:09 BilalAlam173

The default type of a <button> is submit anyways. So it shouldn't make any difference if it is removed...?

schadenn avatar Sep 26 '19 13:09 schadenn

This should be fixed in the latest release of stencil, but indeed the default value is "submit"

manucorporat avatar Sep 26 '19 14:09 manucorporat

@schadenn yes, but if I wanted to query that button with submit value in my code I cant do that if it is removed, I will have to work it around, assign an Id selector and use that to query.

BilalAlam173 avatar Sep 27 '19 06:09 BilalAlam173