mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Don't emit autoFocus={false} attribute on the server (#11543)
This commit is contained in:
@@ -382,6 +382,21 @@ describe('ReactDOMServer', () => {
|
||||
expect(element.firstChild.focus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not focus on either server or client with autofocus={false}', () => {
|
||||
var element = document.createElement('div');
|
||||
element.innerHTML = ReactDOMServer.renderToString(
|
||||
<input autoFocus={false} />,
|
||||
);
|
||||
expect(element.firstChild.autofocus).toBe(false);
|
||||
|
||||
element.firstChild.focus = jest.fn();
|
||||
ReactDOM.hydrate(<input autoFocus={false} />, element);
|
||||
expect(element.firstChild.focus).not.toHaveBeenCalled();
|
||||
|
||||
ReactDOM.render(<input autoFocus={false} />, element);
|
||||
expect(element.firstChild.focus).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should throw with silly args', () => {
|
||||
expect(
|
||||
ReactDOMServer.renderToString.bind(ReactDOMServer, {x: 123}),
|
||||
|
||||
+3
-3
@@ -20,11 +20,11 @@ var HTMLDOMPropertyConfig = {
|
||||
// name warnings.
|
||||
Properties: {
|
||||
allowFullScreen: HAS_BOOLEAN_VALUE,
|
||||
autoFocus: HAS_STRING_BOOLEAN_VALUE,
|
||||
// specifies target context for links with `preload` type
|
||||
async: HAS_BOOLEAN_VALUE,
|
||||
// autoFocus is polyfilled/normalized by AutoFocusUtils
|
||||
// autoFocus: HAS_BOOLEAN_VALUE,
|
||||
// Note: there is a special case that prevents it from being written to the DOM
|
||||
// on the client side because the browsers are inconsistent. Instead we call focus().
|
||||
autoFocus: HAS_BOOLEAN_VALUE,
|
||||
autoPlay: HAS_BOOLEAN_VALUE,
|
||||
capture: HAS_OVERLOADED_BOOLEAN_VALUE,
|
||||
checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
|
||||
|
||||
Reference in New Issue
Block a user