-
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
Why doesn't ReactJS passthrough "unknown" DOM properties? #1730
Comments
Regarding the specific attribute, React favors the DOM API property names for attributes rather than HTML since they were designed to be usable JS identifiers, so we use Regarding the rendering of all attributes, there are a number of issues in play. Most importantly, if you use |
There are a number of different ways I can think of to accomplish this. It's unfortunate that React hasn't gotten over this hump yet. Thanks for the info about the |
It's not that React doesn't trust the developer, but that the various properties behave differently in browsers. For more info about the different kinds of attributes that we need to distinguish between, see the list of attributes/properties here: It's possible that this can be autodetected (see #1512) but right now we're just shipping the hardcoded list. I'd love to hear other suggestions for what we could do. We already have #140 open to track the ability to customize the custom attribute list. |
Have we considered something like an I like it in the sense that it would work like |
@petehunt Thanks for explaining. In case it helps others, this Mozilla HTMLLabelElement page documents that |
@Swivelgames by the way, old android (2.x) stock browsers have issues with reserved words as a properties of objects. as much as weird as it sounds, for android 2.3 you'll have to refer to a reserved word as |
@petehunt @spicyj I got React to work with XML type DOM by patching https://gist.github.com/chinchang/a66fe3aedaf98b2433eb All DOM diff-ing works great! |
For instance, at the moment I have a
<label>
, that contains a validfor
attribute. However, ReactJS (being the baby that it is) doesn't understand thisfor
attribute... Instead of assuming the developer knows what the hell (s)he's doing, it strips it out and leaves a lovely comment about it in the console.This is incredibly frustrating. I don't want it to strip out attributes that it doesn't understand. I just want it to pass them through. In addition to React's inability to provide adequate support for attributes that have existed since HTML 1.0, what happens when the HTML spec changes and new attributes are available for existing elements?
The bug here and issue being provided is not related to the
for
attribute, but to React's inability to trust that the developer knows what they're doing. The real bug here is that React assumes the developer does NOT know what they're doing, and strips out unknown attributes out of fear. This is much less than ideal and should be remedied.The text was updated successfully, but these errors were encountered: