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

App breaks when using both HTML style and inline style. #4317

Closed
vuphuctho opened this issue Aug 11, 2021 · 2 comments · Fixed by #4319
Closed

App breaks when using both HTML style and inline style. #4317

vuphuctho opened this issue Aug 11, 2021 · 2 comments · Fixed by #4319
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has workaround A workaround has been found to avoid the problem 🐞 bug Something isn't working

Comments

@vuphuctho
Copy link

vuphuctho commented Aug 11, 2021

Version

3.2.2

Reproduction link

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHRlbXBsYXRlPlxuICA8aDEgc3R5bGU9XCJmb250LXNpemU6IDM0cHhcIiA6c3R5bGU9XCJ7ICdmb250LXdlaWdodCc6ICdib2xkJ31cIj5IZWxsbyBXb3JsZDwvaDE+XG48L3RlbXBsYXRlPlxuXG48c2NyaXB0IHNldHVwPlxuY29uc3QgbXNnID0gJ0hlbGxvIFdvcmxkISdcbjwvc2NyaXB0PiJ9

Steps to reproduce

Using both style and :style breaks the app.

Minimal code to reproduce:

<h1 style="font-size: 34px" :style="{ 'font-weight': 'bold'}">Hello World</h1>

What is expected?

Both styles should be applied together

What is actually happening?

App crashes.

In Firefox following error message is seen:

Uncaught TypeError: CSS2Properties doesn't have an indexed property setter for '0'

In Chrome:

Uncaught TypeError: Failed to set an indexed property on 'CSSStyleDeclaration': Indexed property setter is not supported.

I don't know the exact version this issue start to happen, but same code works with vue 2.6.14. The same code works for me in Vue 3, until I update the package today.

@edison1105
Copy link
Member

as a workaround use v-bind instead, see sfc

@edison1105 edison1105 added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. has workaround A workaround has been found to avoid the problem labels Aug 11, 2021
@yyx990803 yyx990803 added the 🐞 bug Something isn't working label Aug 16, 2021
yyx990803 pushed a commit that referenced this issue Aug 16, 2021
where static `style` attribute and `:style` with constant binding are used together

fix #4317
@yyx990803
Copy link
Member

Note this only happens if both style and :style are used AND the value of :style is a constant (not referring any component state). Quite an edge case here...

@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. 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.

4 participants
@yyx990803 @vuphuctho @edison1105 and others