-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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
Pass all SVG attributes through #5714
Conversation
This seems good.
I thought I had a third thing too but I forget now. |
@@ -29,6 +29,7 @@ var DOMPropertyInjection = { | |||
HAS_NUMERIC_VALUE: 0x10, | |||
HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10, | |||
HAS_OVERLOADED_BOOLEAN_VALUE: 0x40, | |||
IS_DEPRECATED_PROPERTY: 0x100, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep this, it should be 0x80
.
Amended the commit based on your comments. I added a completely separate code path for the SVG warning so it's easy to remove later and we don't have to think about |
@gaearon updated the pull request. |
@gaearon updated the pull request. |
I updated the PR with what I believe to be the complete implementation, but I haven't tested it in the wild yet. Does it look good to go otherwise? |
@gaearon updated the pull request. |
1 similar comment
@gaearon updated the pull request. |
One thing that concerned me is whether I should add new ReactPerf.measureMethods(DOMPropertyOperations, 'DOMPropertyOperations', {
setValueForProperty: 'setValueForProperty',
setValueForAttribute: 'setValueForAttribute',
deleteValueForProperty: 'deleteValueForProperty',
}); at the bottom. |
return ''; | ||
} | ||
var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? | ||
DOMProperty.properties[name] : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 2 space indent (you have a couple of this exact 2 lines doing the same thing - maybe have a helper method?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to follow the existing style in this file.
Here are a few places I haven't touched where indentation is the same as mine, and they also don't bother to extract the helper function:
I'm happy to re-indent all of them at once and add a helper for getting the property, if you'd like! Just wanted to avoid introducing inconsistencies. Also I didn't want to overgeneralize because this code will later be likely removed when we kill the deprecation path and just start treating SVG pretty much like custom components.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's just leave it as is then 👍
All attributes defined on SVG elements will now be passed directly regardless of the whitelist. The casing specified by user will be preserved, and setAttribute() will be used. In the future we will remove support for the camel case aliases to the hyphenated attributes. For example, we currently map `strokeWidth` to `stroke-width` but this is now deprecated behind a warning. When we remove support for this we can remove some of the code paths introduced in this commit. The purpose of this change is to stop maintaining a separate SVG property config. The config still exists for two purposes: * Allow a migration path for deprecated camelcased versions of hyphenated SVG attributes * Track special namespaced attributes (they still require a whitelist) However it is no longer a blocker for using new non-namespaced SVG attributes, and users don't have to ask us to add them to the whitelist. Fixes #1657
@gaearon updated the pull request. |
In #5590 a new system was introduced for tracking dev-time warnings. This commit uses it for reporting SVG attribute deprecation warnings.
@gaearon updated the pull request. |
@@ -862,6 +864,11 @@ ReactDOMComponent.Mixin = { | |||
DOMProperty.properties[propKey] || | |||
DOMProperty.isCustomAttribute(propKey)) { | |||
DOMPropertyOperations.deleteValueForProperty(getNode(this), propKey); | |||
} else if (this._namespaceURI === DOMNamespaces.svg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean for this to be above the previous case? I think it works out the same either way, so I guess it doesn't really matter.
I see that this change is not in the 0.14.x branch. Will this be backported? |
No this will not be backported. |
This was reverted, so could the OP be updated to reflect that? Lots of issues for SVG point to this one, it confused me before more googling led me to #6243 |
Updated |
Update: this was reverted in favor of a different approach in #6243.
If any attribute is missing please file an issue and we'll add it.
All attributes defined on SVG elements will now be passed directly regardless of the whitelist.
The casing specified by user will be preserved, and
setAttribute()
will be used.In the future we will remove support for the camel case aliases to the hyphenated attributes. For example, we currently map
strokeWidth
tostroke-width
but this is now deprecated behind a warning. When we remove support for this, we can remove some of the code paths introduced in this commit.The purpose of this change is to stop maintaining a separate SVG property config.
The config still exists for two purposes:
However it is no longer a blocker for using new non-namespaced SVG attributes, and users don't have to ask us to add them to the whitelist.
Fixes #1657
Reviewers: @spicyj @jimfb @sebmarkbage