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

the styleModule has problems handling style updates with attribute values of 0 #1093

Closed
chuifengji opened this issue Jan 15, 2024 · 5 comments

Comments

@chuifengji
Copy link

the styleModule has problems handling style updates with attribute values of 0

for (name in oldStyle) {
    if (!style[name]) { // here's the mistake
      if (name[0] === "-" && name[1] === "-") {
        (elm as any).style.removeProperty(name);
      } else {
        (elm as any).style[name] = "";
      }
    }
  }

The above code should be changed to:

for (name in oldStyle) {
    if (!(name in style)) { // how to fix it
      if (name[0] === "-" && name[1] === "-") {
        (elm as any).style.removeProperty(name);
      } else {
        (elm as any).style[name] = "";
      }
    }
  }
@chuifengji
Copy link
Author

I run into this problem when the flex-shrink value is 0

@paldepind
Copy link
Member

Thank you for reporting this @chuifengji. I'll take a look at this.

In the meantime, I think you should be able to work around the problem by using "0" instead of just 0 as your flex-shrink value.

@paldepind
Copy link
Member

Can you describe exactly what problem you are experiencing? I can see that the line you highlight is not ideal, but it's not clear how this results in a bug (except for the property being set to "" and then re-set correctly when the new properties are handled).

@paldepind
Copy link
Member

@chuifengji Please see #1094 which should fix your problem.

@chuifengji
Copy link
Author

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants