dillon1000/react

Commit

Custom Attributes Scenario 2: Write badly cased attributes. Remove most of whitelist. (#10385)

* Allow custom attributes. Add flag to toggle custom attribute behavior

* Update custom attribute logic

- Only allow string attributes
- Remove custom attribute feature flag
- Add additional tests for data, aria, and custom attributes

* Allow numbers and booleans custom attributes. Cut isCustomAttribute

* Cover objects with custom attributes in warning test

* Rename DOMProperty.isWriteable to shouldSetAttribute

* Rework conditions in shouldSetProperty to avoid edge cases

* Update unknown property warning to include custom attribute information

* Remove ref and key from reserved props

* Ensure SSR test coverage for DOMProperty injections

* Add ajaxify attribute for internal FB support

* Ajaxify is a stringifiable object attribute

* Remove non-case sensitive standard attributes. Make ARIA hook dev only.

* Update test name for custom attributes on custom elements

* Remove SSR custom injection test

* Remove case sensitive props

* Remove onAfterResetModules hooks in SSR render tests

* Add back a few attributes and explain why they are needed

* Remove possibleStandardNames from DOMProperty.js

* Fix typo in HTMLPropertyConfig comment

* Remove duplicative comment

* Add back loop boolean property

* Do not allow assignment of attributes that are aliased

* Update custom attribute test to check value, not just presence

* Address case where class is assigned as an attribute on custom elements. Improve SSR tests

* Cover cases where className and for are given to custom elements

* Remove unnecessary spys on console.error. Reduce extra space in tests

* Cover cased custom attributes in SSR tests

* Custom attributes are case sensitive

* Allow uppercase letters in custom attributes. Address associated edge cases

* Allow improperly cased aliased attributes. Add additional tests

* Handle special properties like onFocusOut

* Add some comments to document where casing matters. Remove DOMPropertyNames

* Fix spelling mistake in ajaxify HTML property comment

* Make ARIA enforcement dev-only

* Remove alias test that covers multiple aliases for one property

* Fix typo in comment

* Build SVG aliases dynamically

* Remove unused DOMPropertyNames reference

* Do not translate bad casings of aliased attributes

- classname writes to the DOM as classname
- class does not write to the DOM
- cLASS does not write to the DOM
- arabic-form does not write to the DOM

* Revise the way custom booleans are treated

- Custom attributes can not have boolean values unless they are aria
  or data attributes
- Attributes with boolean values have been added back to the whitelist
- Warnings now exclude booleans from supported types
- Associated test coverage

* Add developer warnings for NaN and ARIA hooks

* Use string comparison instead of regex to check for data and aria attributes.

* Warn about unsupported properties without case sensitivity

* Remove attributes that are updated to invalid values

* Support object property values with toString methods. Allow boolean props to coerce objects

* Add back ajaxify test

* Address bad references in ReactDOMComponent-test. Format.

* Revert changes to the docs

We'll update them separately

* Allow all objects and pass incorrect aliases
Browse files
Changed paths18 files
First-parent comparison
M src/renderers/dom/fiber/ReactDOMFiberComponent.js ModifiedD src/renderers/dom/shared/ARIADOMPropertyConfig.js DeletedM src/renderers/dom/shared/DOMMarkupOperations.js ModifiedM src/renderers/dom/shared/DOMProperty.js ModifiedM src/renderers/dom/shared/DOMPropertyOperations.js ModifiedM src/renderers/dom/shared/HTMLDOMPropertyConfig.js ModifiedM src/renderers/dom/shared/ReactDOMInjection.js ModifiedM src/renderers/dom/shared/SVGDOMPropertyConfig.js ModifiedM src/renderers/dom/shared/__tests__/DOMPropertyOperations-test.js ModifiedM src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js ModifiedM src/renderers/dom/shared/__tests__/ReactDOMInvalidARIAHook-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 ModifiedA src/renderers/dom/shared/hooks/possibleStandardNames.js AddedA src/renderers/dom/shared/hooks/validAriaProperties.js AddedM src/renderers/dom/shared/utils/assertValidProps.js ModifiedM src/renderers/dom/stack/client/ReactDOMComponent.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…