snabbdom / snabbdom

A virtual DOM library with focus on simplicity, modularity, powerful features and performance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

chuifengji opened this issue · comments

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] = "";
      }
    }
  }

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

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.

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).

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

thanks!