When using material-ui with Server Side Rendering -
There should be no validation issues shown by https://validator.w3.org
There are many validation issues thrown by https://validator.w3.org when using Material-UI with server side rendering
I want to create an application which validates with W3C validator.
| Tech | Version |
|--------------|---------|
| Material-UI | 1.0.0-beta.27 |
| React | 16.2.0 |
| browser | |
| etc | |
Wow, that's quite some list! 😳
We'd be grateful if you were to submit a PR (many PRs?! 😅 ) for the low-hanging fruit.
@mbrookes I will surely try to submit some PRs to fix the errors of validation. Warnings may be ignored for now.
Actually having my app rendered as server-side exposes these errors.
I am not sure of how beneficial it is to have 100% validated markup, but in my case it is a requirement from the stakeholders.
It might require some fixes in Next.js side.
I am not sure of how beneficial it is to have 100% validated markup
It will help with Material-UI credibility.
I have been fixing some of the issues. I'm more or less stuck with the homepage. Ideally, I would also scan all the pages.
@oliviertassinari Your changes have taken care of many errors. I have submitted a small change now as well.
If you fix the duplicate ids issue and the _target property used on div (also on every page) then Most of it would be closed already.
BTW, thank you for the quick turnaround time for fixing most of the issues.
@sambhav-gore I'm wondering if we shouldn't close the issue now. I believe the last issues are Next.js relative.
@oliviertassinari I still see some issues, I will list it all down here in a comment and then you can take a call about whether this can be closed.
Following are the issues which IMO are related to the core styles of components. I am listing here the demo page name (under components demo) and the issue reported by w3c and my reasoning of it
-webkit-appearance and -moz-appearance based on the browser used. W3C is also expecting a fallback appearance property valueTypography creates a span to wrap h1, h2 and other headings. this is not allowed by validatorhr is used as a direct chid of ul (I am not 100% sure if this is in component source or demo/docs only)px or pc or % but it is not mentioned in the specs. However, I spent some time looking at it but I was not sure if the numbers were meant to be percentages. If they are indeed percentage I think adding a unit is best. See this file src/Progress/CircularProgress.js fieldsetdemo-github|demo-codesandbox|demo-source}Finally, As long as users can generate valid markup by using components slightly differently tahn in demo it is okay. My main concern is when an error is generated from core styles.
@sambhav-gore Wow, thanks for the detailed list!
My main concern is when an error is generated from core styles.
We can split the work then. I will focus on the documentation issues :).
Can you confirm about the CircularProgress listed above in the list ? It is a percentage value ?
It should be px.
@oliviertassinari I have created a PR to fix all of the issues from the list above except for the first one - appearance as it is hard to find out where the magic or vendor prefix happening, may be that lib has a config to fix it. anyway since it is a build time issue it is not related to the source code.
Please let me know if my changes cause any issues as I am still quite new to material-ui
@oliviertassinari after digging a lot more I found the root cause of 1st point in my list the appearance: textfield error. It seems that the JSS generated on SSR is different than that of in-browser:
.jss220 {
appearance: textfield;
}
.jss273 {
-webkit-appearance: textfield;
}
The SSR one is wrong since spec doesn't have textfield value for appearance yet. Now to me it looks like a jss issue. right ?
On second thoughts, following can be changed to have vendor prefixes for webkit and moz since textfield is not a valid value for appearance anyway.
It seems that the JSS generated on SSR is different than that of in-browser:
JSS doesn't vendor prefix on the server. It's up to the users, at least, it's what @kof is suggesting. I haven't tried yet.
As of right now, yes, we should change this though.
[Selection Control]
Error: Attribute “required” not allowed on element “fieldset” at this point
Reason: required is used on fieldset
I'm working on it.
[Lists]:
Error: Bad value “button” for attribute “role” on element “li”
Reason: May be demo error only.
I'm working on it.
I'm working on the last appearance issue.
@sambhav-gore We should be good now. Feel free to report and fix the w3c issues that we have missed :). Thanks a lot for raising the concern. It's important for the vision of the project that goes beyond Material Design.
IMO and a suggestion, fixing w3c issues using https://validator.w3.org will not help much when using modern web technologies. In my project it gave me an error Element style not allowed as child of element body in this context. (Suppressing further errors from this subtree.) .It wants the <style> tag in the <head>, not in a <div> or anything inside the <body>. This explains this issue. For apps that SSR, following tools are much more helpful.
google speed Insight,
gmetrix for speed & server tech