Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot remove size attribute of <input>. #3576

Closed
ota-meshi opened this issue Apr 9, 2021 · 4 comments · Fixed by #3578
Closed

Cannot remove size attribute of <input>. #3576

ota-meshi opened this issue Apr 9, 2021 · 4 comments · Fixed by #3578
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working

Comments

@ota-meshi
Copy link
Member

ota-meshi commented Apr 9, 2021

Version

3.0.11

Reproduction link

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8aW5wdXQgOnNpemU9XCJzaXplXCIgPlxuPC90ZW1wbGF0ZT5cblxuPHNjcmlwdD5cbmV4cG9ydCBkZWZhdWx0IHtcbiAgZGF0YSAoKSB7XG5cdFx0cmV0dXJuIHtcbiAgICAgIHNpemU6IG51bGwsXG4gICAgfSBcbiAgfSBcbn1cbjwvc2NyaXB0PiJ9

Steps to reproduce

  • Open the link.
  • Display error: Uncaught (in promise): Failed to set the 'size' property on 'HTMLInputElement': The value provided is 0, which is an invalid size.

What is expected?

Renders <input> without the size attribute because I specified null for the size.

What is actually happening?

An error will occur.


Even if undefined is given, an error will occur.

@edison1105
Copy link
Member

duplicate of #3294

@ota-meshi
Copy link
Member Author

ota-meshi commented Apr 9, 2021

Hi @edison1105.

That issue looked to me like <input :size="0"> issue.
This issue is <input :size="null"> issue.

How do I remove the size attribute?

@edison1105
Copy link
Member

Is this what you want?

<template>
  <input ref="el" :size="size" >
</template>

<script>
export default {
  data () {
    return {
      size: 1,
    } 
  },
  mounted(){
    this.$refs.el.setAttribute('size',1)
    this.$refs.el.removeAttribute('size')
  }
}
</script>

@posva
Copy link
Member

posva commented Apr 9, 2021

maybe we should remove the size attribute if it's set to null (like with other attributes).

You should also be able to use an object with v-bind and remove the size property from that object

@posva posva added 🐞 bug Something isn't working 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. has workaround A workaround has been found to avoid the problem labels Apr 9, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants