-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Fix boolean element attributes as per HTML5 spec #993
Conversation
Fixes #961 |
@@ -94,6 +94,9 @@ var DOMPropertyOperations = { | |||
if (shouldIgnoreValue(name, value)) { | |||
return ''; | |||
} | |||
if (value === true && DOMProperty.hasBooleanValue[name]) { |
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.
Shouldn't that just be:
if (value && DOMProperty.hasBooleanValue[name]) {
If it's a boolean, then it's a boolean.
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 think it has to be if a value is strictly true
, and not just truey. Otherwise a value of "myAttrValue" would emit a bare attribute. I guess that might be favourable to force HTML5 compliance. But it takes away the ability to target XHTML with disabled="disabled"
(if that matters).
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.
@jjt The issue I see with only strictly true
values is that most things people use as booleans are often not strictly true
or false
, I mean even Var1 || Var2
could be anything.
As for XHTML, I'm not sure if React is even compatible with it anyway (and who even uses it, hehe), if that is something we strive to support (do we?) then I would argue that it's better to detect it and always mirror the key in the value, rather than this weird in-between.
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.
What? People play it fast and loose with js types?!!?
I tend to agree with you though inre: no XHTML support. It would fit with the current system of passing a falsey value to omit an attribute.
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 say screw XHTML support and go bare. We've already decided we aren't ignoring the value (shouldIgnoreValue
), so I think we should do it for all hasBooleanValue
properties.
@jjt Have you double-checked that all attributes marked as |
@syranide Yup, I went through the attributes and cross-referenced them with the ones in the spec. |
@@ -94,6 +94,9 @@ var DOMPropertyOperations = { | |||
if (shouldIgnoreValue(name, value)) { | |||
return ''; | |||
} | |||
if (value === true && DOMProperty.hasBooleanValue[name]) { | |||
return escapeTextForBrowser(name); |
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.
We should be using attributeName
just in case they don't match up.
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.
Right, good call.
key should never be index into an array or there are bugs. Especially in transitions. Fixes facebook#853
We've been able to use `querySelectorAll` in all the browsers that we support for some time now, but we haven't been able to test code that uses it in the older version of `jsdom` that we were using, until recently. Besides the general goal of modernizing our code, the impetus for this specific change is that I'm trying to support testing without having to render nodes into an actual document. The `.getElementsByName` method is only defined on `document` and only works if the nodes you care about are contained by the document. On the other hand, `querySelectorAll` works on any DOM node, and allows a more precise selection of just the `<input type="radio">` elements that have the appropriate name. IE8's implementation of `querySelectorAll` supports attribute-based selectors, which is all we need here.
Numeric keys will be ordered sequentially in Chrome/Firefox. Warn the user if such keys are set on a child.
We're not handling these correctly.
Number('.1') === 0.1, and react uses dot-prefixed keys for children. Whoops. Nuke the non-numeric requirement, and just check a regex. This seems performant enough in micro-benchmarks: http://jsperf.com/numericlike
Recently learned that components passed into `React.renderComponent` may not be the ones actually mounted. Also learned that it returns the mounted component. Added some documentation describing this.
Let's be consistent with the naming
Alright, it's using |
@jjt Saw that you proposed using |
Nuking this one, see #1005 |
@jjt FYI, if you run into this again, |
@syranide Thanks, I'll look into that. I know just enough about git workflows to get myself into trouble, so it would be good to know how to dig myself out. |
@syranide Heh, thanks for the reassurance! |
No description provided.