dillon1000/react

Commit

Changes to attribute whitelist logic (#10564)

* Remove HTMLPropertyConfig entries for non-boolean values

When we originally removed attributes from the whitelist, we assumed a
few attributes were string booleans, but they are not:

Autocomplete ("on", "off")
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autocomplete

Autocapitalize ("none", "sentence", "words", ...)
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autocapitalize

Autocorrect ("on", "off")
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autocorrect

Autosave (string)
https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html#autosave

* Only HAS_BOOLEAN_VALUE attribute flag can assign booleans

* Use a non-boolean attribute in object assignment tests

* Add HAS_STRING_BOOLEAN_VALUE attribute flag

* Fix boolean tests, add boolean warning.

* Reserved props should allow booleans

* Remove outdated comments

* Style tweaks

* Don't treat dashed SVG tags as custom elements

* SVG elements like font-face are not custom attributes

- Adds exceptions to isCustomAttribute for dashed SVG elements
- Use consistent custom element check across all modules

* Move namespace check to isCustomAttribute. Add caveat for stack.

* Remove unused namespace variable assignment

* Fix the DEV-only whitelist

* Don't read property twice

* Ignore and warn about non-string `is` attribute

* Blacklist "aria" and "data" attributes

* Don't pass unknown on* attributes through

* Remove dead code

* Avoid accessing namespace when possible

* Drop .only in ReactDOMComponent-test

* Make isCustomComponent logic more solid

* Do attribute name check earlier

* Fix fbjs import

* Revert unintentional edit

* Re-allow "data" attribute

We intentionally allowed it.

* Use stricter check when attaching events

* Pass SVG boolean attributes with correct casing

* Fix the test

* Undo the SVG dashed-name fix

Per conversation with @sebmarkbage we decided that the fix is too complicated, and it's unfortunate it depends on the DOM element.
It's only relevant for super rare tags that aren't even working consistently across browsers so we'll leave it unfixed for now.

* Prettier

* Fix lint

* Fix flow

* Pass "aria" through but still warn

* Remove special cases for onfocusin, onfocusout

They're covered by event handler code now.

* Add a more specific warning for unknown events

* Pass badly cased React attributes through with warning
Browse files
Changed paths13 files
First-parent comparison
M src/renderers/dom/fiber/ReactDOMFiberComponent.js ModifiedM src/renderers/dom/shared/DOMMarkupOperations.js ModifiedM src/renderers/dom/shared/DOMProperty.js ModifiedM src/renderers/dom/shared/HTMLDOMPropertyConfig.js ModifiedM src/renderers/dom/shared/SVGDOMPropertyConfig.js ModifiedM src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js ModifiedM src/renderers/dom/shared/__tests__/ReactDOMServerIntegration-test.js ModifiedM src/renderers/dom/shared/hooks/ReactDOMInvalidARIAHook.js ModifiedM src/renderers/dom/shared/hooks/ReactDOMUnknownPropertyHook.js ModifiedM src/renderers/dom/shared/hooks/possibleStandardNames.js ModifiedM src/renderers/dom/shared/utils/isCustomComponent.js ModifiedM src/renderers/dom/stack/client/ReactDOMComponent.js ModifiedM src/renderers/shared/server/ReactPartialRenderer.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…