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

Providing null to a readonly property of a HTMLElement leads to an error instead of a warning #5545

Closed
atilleul opened this issue Mar 8, 2022 · 1 comment
Labels
🐞 bug Something isn't working

Comments

@atilleul
Copy link

atilleul commented Mar 8, 2022

Version

3.2.31

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Writing <template><select id="foo" name="foo" :type="undefined" /></template> in a Vue component to see an error in the console: type is a read-only property of HTMLSelectElement.

Browsers:

  • Microsoft Edge Version 99.0.1150.30 (Official build) (64-bit)
  • Chrome Version 99.0.4844.51 (Official Build) (64-bit)

Error in the console: TypeError: Cannot set property type of #<HTMLSelectElement> which has only a getter (runtime-dom.esm-bundler.js?830f:261)

Browser:

  • Firefox Version 98.0 (64-bit)

Error in the console: TypeError: setting getter-only property "type"

What is expected?

Writing <select id="foo" name="foo" type="bar" /> in the template throws a warning and not an error. This is what we should have also when value == null.

What is actually happening?

A JavaScript error is thrown instead of a warning.


In the function patchDOMProp of runtime-dom.esm-bundler.js, it tries to set an empty string to the read-only property: el[key] = '';. The error should be managed by wrapping this line into a try/catch.

@LinusBorg LinusBorg added the ✨ feature request New feature or request label Mar 9, 2022
@sudongyuer
Copy link
Contributor

#5550 solved

zscumt123 pushed a commit to zscumt123/core that referenced this issue Mar 9, 2022
@LinusBorg LinusBorg added 🐞 bug Something isn't working ✨ feature request New feature or request and removed ✨ feature request New feature or request labels Mar 12, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Sep 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants