Update cycles do not update MsTransform in IE11
We use quite a bit of inline transforms in our components, and I've recently encountered that these transforms are not updated in IE after the component is mounted. So on mounting, the component receive the correct transform styling; but it remains unchanged through subsequent update cycles.
They only update if the component has a unique key for each update cycle. They do not update for no-key components or components with static keys.
I've verified that other styling properties seem to update fine (i.e. opacity).
What does your style property look like?
Compiled from coffeescript and cleaned up for brevity (the actual version would have all the polyfills for transform).
Opacity correctly updated every time the component was selected. But transform would get set to "translateY(10px)" at mount time and remain so.
renderSelectedText = function() {
var style, transform;
style = {
opacity: this.state.selected ? 1 : 0,
MsTransform: this.state.selected ? "translateY(-10px)" : "translateY(10px)",
transform: this.state.selected ? "translateY(-10px)" : "translateY(10px)"
};
return React.DOM.div({
className: "followed-text",
style: style
}, CheckMark({
color: "#FFF",
width: 50,
height: 50,
thickness: 3,
circle: true
}));
},
The prefix should be ms, hence msTransform. I believe what's happening is simply that React is setting unknown styles as well in the initial markup, but when it goes to update node.style.MsTransform it's an unknown property and hence the property change isn't reflected in the DOM.
@zpao Considering we enforce the camelCasing for everything else, how 'bout we do the same for vendor-prefixes and change to oFoo, msFoo, webkitFoo, mozFoo, etc? (Or at the very least change ms to Ms to be consistent... EDIT: but then we'd have to check/transform all style names, bah! But perhaps it makes sense to keep a CSS whitelist too? For much needed warnings...)
Damn. There's me trying to be super smart with Ms because everything else is Webkit/Moz. Looks like changing it back to ms works. It seems to me that accepting "bad" style at mounting time is grounds for confusion though. Why not just throw an error/not apply the style if it's bad so it'll be easier to trace down?
And also, why was 'ms' left out of your Webkit/Moz casing? :p.
We follow the same rules here that you must follow when setting styles directly from JS. I don't know the history but Microsoft didn't follow the rules for vendor prefixes (to be fair the rules might not have been standardized when they started). So msWhatever is the exception to the rule.
The reason this works on first render is that we have to transform the JS style name to the CSS one, which follows a simple pattern - take each uppercase letter and replace it with a hyphen and the lowercase version. So MsTransform becomes -ms-transform, which is actually the right thing. But then on updates we don't update the style (we do actually try) because node.style.MsTransform isn't a property IE knows to parse.
We actually have a warning for bad vendor prefixes (https://github.com/facebook/react/blob/master/src/browser/ui/dom/CSSPropertyOperations.js#L38), but we don't check for Ms. Perhaps we should.
@syranide we don't enforce camelCasing for style properties, the browser just does that for us, so I don't think we should deviate here and use Ms.
@zpao But... node.style.webkit* is used by Webkit, but we enforce uppercase I think? I always thought that the camelCasing in React was largely from the perspective of the JavaScript implementation of the DOM, not the HTML. So it seems to me it makes more sense to use webkit* rather than Webkit*.
Also, if I would hazard a guess, I would say that the leading hyphen in -webkit-* only signifies it being unofficial. It doesn't make sense that it would be added because the CSS property really is intended to be read as Webkit*... which also matches the fact that node.style.webkit* is the vendor-prefix in JavaScript.
Or?
Ah...I guess the problem here has always been the inconsistent casing of these vendor prefixes in JS. It's indeed node.style.webkitWhatever for webkit in JS.
Thanks for the help and all the explanations guys.
Yea, I can't actually find anything talking about any official rules. I thought I had at some point. Ah well. Regardless, Webkit actually makes both work, webkitFoo and WebkitFoo. I'm not sure which is the primary but they can be used interchangably.
I would say that the leading hyphen in -webkit-* only signifies it being unofficial.
I'm not really sure what you mean here. All CSS vendor prefixes are "unofficial". Most are not intended to live forever as specs develop. Others are just totally off-spec and might never become a standard.
I'm not really sure what you mean here. All CSS vendor prefixes are "unofficial". Most are not intended to live forever as specs develop. Others are just totally off-spec and might never become a standard.
@zpao Ah, what I meant was that I'm pretty sure that -webkit-whatever is meant to be read as webkitWhatever (as it actually is in Webkit, not all browsers though) even though it technically should be WebkitWhatever due to the leading hyphen... but... I guess there's something to be said in-favor of WebkitWhatever and that would be that there cannot be accidental conflicts (however unlikely) and again kind of speaks for its "unofficial" nature.
So regardless of which one is preferred, it makes sense to me that React should normalize and use the same casing for all vendor-prefixes. It's also really weird currently because the JavaScript-prefixes are webkit, ms, Moz, O but React has it set to Webkit, ms, Moz, O which makes no sense at all to me?
EDIT. webkitWhatever is the correct one I assume, as it's the only one that is shown in the auto-complete list (hence what my reaction to Webkit being used in React rather than webkit).