-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
[jss-vendor-prefixer] Naive use of content
prop causes uncaught error in IE
#242
Comments
content
prop causes uncaught error in IEcontent
prop causes uncaught error in IE
Can you give me an example of jss code you are using? |
Is this enough to reproduce? {
button: {
'&:after': {
content: ''
}
}
} |
I was always wondering whether jss should just simply check the |
Here is the code I am using to reproduce it now: index.jsx: import React from "react";
import ReactDOM from "react-dom";
import Root from "./root";
ReactDOM.render((
<Root />
), document.getElementById("exampleApp")); root.jsx: import React from "react";
import jss from "./jss-preset";
import useSheet from "react-jss";
const styles = {
foo: {
"&:after": {
display: "block",
content: "bar"
}
}
};
const Root = ({
sheet: { classes }
}) => {
return <h1 className={classes.foo}>Hello World</h1>
};
export default useSheet(Root, styles); jss-preset.js: import jss from "jss";
import jssExtend from "jss-extend";
import jssNested from "jss-nested";
import jssCamelCase from "jss-camel-case";
import jssDefaultUnit from "jss-default-unit";
import jssVendorPrefixer from "jss-vendor-prefixer";
jss.use(jssExtend());
jss.use(jssNested());
jss.use(jssCamelCase());
jss.use(jssDefaultUnit());
jss.use(jssVendorPrefixer());
export default jss; The nesting/pseudo-class is not necessary to reproduce it, just used as it reflects the typical usage pattern. Other properties on the nested selector work fine, and using |
Oh now I recall again why I didn't auto insert them. This would break other cases. There are values for content that can be put there without quotes. https://developer.mozilla.org/de/docs/Web/CSS/content Barium is broken by design. |
The only thing I can optimize there is when content value is an empty string, in this case I can auto insert double quotes. Now back to the original issue. I am really surprised that IE throws a js error in such case. |
Perhaps a warning when the environment is debug to make sure
|
I think someone who is writing it, will test and see if it doesn't work? |
I mean it won't work in any browser, just won't throw error in others than IE. |
please confirm that the error in IE has been fixed. |
you need to remove css-vendor package and install a new version or simply remove everything and install again. |
Verified fixed in IE11, thanks! Interestingly enough, while trying different values, I was still able to get IE to throw an exception when surrounding single quotes with double (e.g. |
Interesting ... wonder what we are currently generating on IE ... never had a problem, so it must be working somehow. |
Hmm, do we need to fix this? |
Your call, I have a white screen when using |
It is fixable in theory, but a bit too much hustle considered this spec: https://developer.mozilla.org/en-US/docs/Web/CSS/content |
I wish this was fixed. I just spent a full day wondering why my css was not working. I wrote normal css and inserted it into a style tag and my css worked. But using the content: "" and trying content: '', after compilation, the content attribute was removed from my class by React-jss. I have no idea why, but wanted to give you a heads up. I'm using Firefox 70 FYI, but it's the compilation process in jss, that seems to remove this. Using the fix mentioned above content: "''" solved the issue. |
@TerrySlack it's not broken, it's just not intuitive, content can contain values without quotes. The only thing I know we can do is to provide warnings in dev mode. |
That would be cool. Curious, could the code not, check for an empty string in the case of content and just overwrite it with " ' ' "?
|
When using the
content
prop (in this case for the usual task of styling pseudo-elements), if escaped quote characters are not passed into the string given as the value, the value ends up getting passed without quotes.While Chrome and Edge pass it through and simply ignore the invalid value, in IE11,
css-vendor/supported-value.js
throws an error:When
jss-vendor-prefixer
is disabled, IE behavior is identical to Chrome/Edge.The text was updated successfully, but these errors were encountered: