-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Element: renderToString
incorrectly lowercases attributes
#12932
Comments
To add to that - it seems to also remove hyphens from SVG attributes, e.g.: |
I confirmed that this is a bug in our custom serializer, React's serializer is a bit different. cc @aduth |
I've started to look at this issue, but have a few additional questions:
wp.element.renderToString( wp.element.createElement( 'font-face', { 'accent-height': 10 } ) )
// "<font-face accent-height="10"></font-face>" |
Not the original reporter but concerning 1: Yes. I for example use the Icon Component to create Dashicon SVG icons. But since the saved HTML is lowercased the block is always broken after first save with |
@kraftner Could you share some specific code? I would expect that since both the block save serialization and parser compare content judged by running both through the same (lowercasing) |
I am sorry, when trying to create a reduced test case I realized I had another problem that caused this. What got me off track was the fact that when clicking on the "Resolve" Button instead of highlighting my actual mistake (having the wrong selector in an attribute definition) the b/B issue of |
If I'm reading this properly, there's no further fixing required. Let me know if I missed anything. |
I'm still having this issue with the lowercased 'b' in viewbox causing the "This block contains unexpected or invalid content" error. The exact same code in ajlende/gutenberg-random-blocks works fine with Maybe my use-case is slightly different since I'm saving the rendered string to an attribute and then displaying it with EDIT: Actually, this might be closer to the issue in #9898 (which is marked as closed but seems to have the most recent activity with other folks commenting on it) |
I'm running into similar issues. My block has some SVG elements in it that include |
Given that the behavior is consistent within |
I'm not bypassing anything... but I was able to resolve the issue. I found an unrelated issue in my block markup that was causing the rendered block markup to be different than the markup from the save() function in my block's code. (It was a sort of random key added to an attribute name) What was odd was that the validator was failing focused on the camelCase of the svg attributes so I was focused on that and didn't see any indication of the diff being incorrect elsewhere in the markup. When I removed that bug and difference in the markup the validation doesn't have an issue with the case of the svg attributes. It is still lowercasing the svg attributes such as There does seem to be an issue though with the validator telling me the error was with the lowercase |
Describe the bug
Calling
renderToString
from@wordpress/element
incorrectly lowercases some attributes, for exampleviewBox
turns intoviewbox
.There are a number of SVG attributes with a capitalized letter in the middle: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute I would think that these are incorrectly lowercased as well.
Expected behavior
renderToString
should work with attributes that have a capitalized letter in the middle.The text was updated successfully, but these errors were encountered: