Skip to content

Commit

Permalink
[react-interactions] Rename Flare listeners prop to DEPRECATED_listeners
Browse files Browse the repository at this point in the history
Apply fixes
  • Loading branch information
trueadm committed Nov 18, 2019
1 parent 3ad0764 commit 73a412e
Show file tree
Hide file tree
Showing 32 changed files with 256 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('ReactHooksInspection', () => {
const listener = React.unstable_useResponder(TestResponder, {
preventDefault: false,
});
return <div listeners={listener}>Hello world</div>;
return <div DEPRECATED_flareListeners={listener}>Hello world</div>;
}
let tree = ReactDebugTools.inspectHooks(Foo, {});
expect(tree).toEqual([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1892,7 +1892,7 @@ describe('ReactDOMServerPartialHydration', () => {

function Button() {
let listener = React.unstable_useResponder(TestResponder, {});
return <a listeners={listener}>Click me</a>;
return <a DEPRECATED_flareListeners={listener}>Click me</a>;
}

function App() {
Expand Down Expand Up @@ -2041,7 +2041,7 @@ describe('ReactDOMServerPartialHydration', () => {

function Button() {
let listener = React.unstable_useResponder(TestResponder, {});
return <a listeners={listener}>Click me</a>;
return <a DEPRECATED_flareListeners={listener}>Click me</a>;
}

function Child() {
Expand Down Expand Up @@ -2408,13 +2408,13 @@ describe('ReactDOMServerPartialHydration', () => {
return (
<div>
<Suspense fallback="Loading First...">
<span listeners={listener1} />
<span DEPRECATED_flareListeners={listener1} />
{/* We suspend after to test what happens when we eager
attach the listener. */}
<First />
</Suspense>
<Suspense fallback="Loading Second...">
<span listeners={listener2}>
<span DEPRECATED_flareListeners={listener2}>
<Second />
</span>
</Suspense>
Expand Down
10 changes: 5 additions & 5 deletions packages/react-dom/src/client/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const AUTOFOCUS = 'autoFocus';
const CHILDREN = 'children';
const STYLE = 'style';
const HTML = '__html';
const LISTENERS = 'listeners';
const DEPRECATED_flareListeners = 'DEPRECATED_flareListeners';

const {html: HTML_NAMESPACE} = Namespaces;

Expand Down Expand Up @@ -346,7 +346,7 @@ function setInitialDOMProperties(
setTextContent(domElement, '' + nextProp);
}
} else if (
(enableFlareAPI && propKey === LISTENERS) ||
(enableFlareAPI && propKey === DEPRECATED_flareListeners) ||
propKey === SUPPRESS_CONTENT_EDITABLE_WARNING ||
propKey === SUPPRESS_HYDRATION_WARNING
) {
Expand Down Expand Up @@ -715,7 +715,7 @@ export function diffProperties(
} else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN) {
// Noop. This is handled by the clear text mechanism.
} else if (
(enableFlareAPI && propKey === LISTENERS) ||
(enableFlareAPI && propKey === DEPRECATED_flareListeners) ||
propKey === SUPPRESS_CONTENT_EDITABLE_WARNING ||
propKey === SUPPRESS_HYDRATION_WARNING
) {
Expand Down Expand Up @@ -810,7 +810,7 @@ export function diffProperties(
(updatePayload = updatePayload || []).push(propKey, '' + nextProp);
}
} else if (
(enableFlareAPI && propKey === LISTENERS) ||
(enableFlareAPI && propKey === DEPRECATED_flareListeners) ||
propKey === SUPPRESS_CONTENT_EDITABLE_WARNING ||
propKey === SUPPRESS_HYDRATION_WARNING
) {
Expand Down Expand Up @@ -1065,7 +1065,7 @@ export function diffHydratedProperties(
if (suppressHydrationWarning) {
// Don't bother comparing. We're ignoring all these warnings.
} else if (
(enableFlareAPI && propKey === LISTENERS) ||
(enableFlareAPI && propKey === DEPRECATED_flareListeners) ||
propKey === SUPPRESS_CONTENT_EDITABLE_WARNING ||
propKey === SUPPRESS_HYDRATION_WARNING ||
// Controlled attributes are not validated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('DOMEventResponderSystem', () => {
function Test() {
const listener = React.unstable_useResponder(TestResponder, {});

return <div listeners={listener}>Hello world</div>;
return <div DEPRECATED_flareListeners={listener}>Hello world</div>;
}
const renderer = ReactTestRenderer.create(<Test />);
expect(renderer).toMatchRenderedOutput(<div>Hello world</div>);
Expand All @@ -108,7 +108,7 @@ describe('DOMEventResponderSystem', () => {
function Test() {
const listener = React.unstable_useResponder(TestResponder, {});

return <div listeners={listener}>Hello world</div>;
return <div DEPRECATED_flareListeners={listener}>Hello world</div>;
}
const output = ReactDOMServer.renderToString(<Test />);
expect(output).toBe(`<div data-reactroot="">Hello world</div>`);
Expand All @@ -127,7 +127,7 @@ describe('DOMEventResponderSystem', () => {

return (
<div>
<span listeners={listener} ref={ref}>
<span DEPRECATED_flareListeners={listener} ref={ref}>
Hello world
</span>
</div>
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('DOMEventResponderSystem', () => {
const listener = React.unstable_useResponder(TestResponder, {});

return (
<button ref={buttonRef} listeners={listener}>
<button ref={buttonRef} DEPRECATED_flareListeners={listener}>
Click me!
</button>
);
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('DOMEventResponderSystem', () => {
const listener = React.unstable_useResponder(TestResponder, {});

return (
<button ref={buttonRef} listeners={listener}>
<button ref={buttonRef} DEPRECATED_flareListeners={listener}>
Click me!
</button>
);
Expand Down Expand Up @@ -270,7 +270,9 @@ describe('DOMEventResponderSystem', () => {
const listener2 = React.unstable_useResponder(TestResponder, {});

return (
<button ref={buttonRef} listeners={[listener, listener2]}>
<button
ref={buttonRef}
DEPRECATED_flareListeners={[listener, listener2]}>
Click me!
</button>
);
Expand Down Expand Up @@ -304,8 +306,8 @@ describe('DOMEventResponderSystem', () => {
const listener = React.unstable_useResponder(TestResponder, {});

return (
<div listeners={listener}>
<button ref={buttonRef} listeners={listener}>
<div DEPRECATED_flareListeners={listener}>
<button ref={buttonRef} DEPRECATED_flareListeners={listener}>
Click me!
</button>
</div>
Expand Down Expand Up @@ -353,7 +355,9 @@ describe('DOMEventResponderSystem', () => {
const listener2 = React.unstable_useResponder(TestResponderB, {});

return (
<button ref={buttonRef} listeners={[listener, listener2]}>
<button
ref={buttonRef}
DEPRECATED_flareListeners={[listener, listener2]}>
Click me!
</button>
);
Expand All @@ -374,8 +378,8 @@ describe('DOMEventResponderSystem', () => {
const listener2 = React.unstable_useResponder(TestResponderB, {});

return (
<div listeners={listener}>
<button ref={buttonRef} listeners={listener2}>
<div DEPRECATED_flareListeners={listener}>
<button ref={buttonRef} DEPRECATED_flareListeners={listener2}>
Click me!
</button>
</div>
Expand Down Expand Up @@ -406,8 +410,8 @@ describe('DOMEventResponderSystem', () => {
const listener = React.unstable_useResponder(TestResponder, {name: 'A'});
const listener2 = React.unstable_useResponder(TestResponder, {name: 'B'});
return (
<div listeners={listener}>
<button ref={buttonRef} listeners={listener2}>
<div DEPRECATED_flareListeners={listener}>
<button ref={buttonRef} DEPRECATED_flareListeners={listener2}>
Click me!
</button>
</div>
Expand Down Expand Up @@ -454,7 +458,7 @@ describe('DOMEventResponderSystem', () => {
});

return (
<button ref={buttonRef} listeners={listener}>
<button ref={buttonRef} DEPRECATED_flareListeners={listener}>
Click me!
</button>
);
Expand Down Expand Up @@ -490,9 +494,9 @@ describe('DOMEventResponderSystem', () => {
const listener = React.unstable_useResponder(TestResponder, {});
const listener2 = React.unstable_useResponder(TestResponder2, {});
if (toggle) {
return <button listeners={[listener2, listener]} />;
return <button DEPRECATED_flareListeners={[listener2, listener]} />;
}
return <button listeners={[listener, listener2]} />;
return <button DEPRECATED_flareListeners={[listener, listener2]} />;
}

ReactDOM.render(<Test />, container);
Expand All @@ -515,15 +519,15 @@ describe('DOMEventResponderSystem', () => {
function Test({test}) {
const listener = React.unstable_useResponder(TestResponder, {});
if (test === 0) {
return <button listeners={[listener]} />;
return <button DEPRECATED_flareListeners={[listener]} />;
} else if (test === 1) {
return <button listeners={null} />;
return <button DEPRECATED_flareListeners={null} />;
} else if (test === 2) {
return <button listeners={[]} />;
return <button DEPRECATED_flareListeners={[]} />;
} else if (test === 3) {
return <button />;
} else if (test === 4) {
return <button listeners={listener} />;
return <button DEPRECATED_flareListeners={listener} />;
}
}

Expand Down Expand Up @@ -563,7 +567,7 @@ describe('DOMEventResponderSystem', () => {

const Test = () => {
const listener = React.unstable_useResponder(TestResponder, {});
return <button listeners={listener} />;
return <button DEPRECATED_flareListeners={listener} />;
};

ReactDOM.render(<Test />, container);
Expand All @@ -590,7 +594,7 @@ describe('DOMEventResponderSystem', () => {

const Test = () => {
const listener = React.unstable_useResponder(TestResponder, {});
return <button listeners={listener}>Click me!</button>;
return <button DEPRECATED_flareListeners={listener}>Click me!</button>;
};

ReactDOM.render(<Test />, container);
Expand Down Expand Up @@ -645,8 +649,8 @@ describe('DOMEventResponderSystem', () => {
const listener2 = React.unstable_useResponder(TestResponderB, {});

return (
<div listeners={listener}>
<button ref={buttonRef} listeners={listener2}>
<div DEPRECATED_flareListeners={listener}>
<button ref={buttonRef} DEPRECATED_flareListeners={listener2}>
Click me!
</button>
</div>
Expand Down Expand Up @@ -709,8 +713,8 @@ describe('DOMEventResponderSystem', () => {
const listener2 = React.unstable_useResponder(TestResponderB, {});

return (
<div listeners={listener}>
<button listeners={listener2}>Click me!</button>
<div DEPRECATED_flareListeners={listener}>
<button DEPRECATED_flareListeners={listener2}>Click me!</button>
</div>
);
};
Expand Down Expand Up @@ -759,7 +763,7 @@ describe('DOMEventResponderSystem', () => {
});

return (
<button listeners={listener} ref={buttonRef}>
<button DEPRECATED_flareListeners={listener} ref={buttonRef}>
Click me!
</button>
);
Expand Down Expand Up @@ -823,7 +827,7 @@ describe('DOMEventResponderSystem', () => {
onFoo: e => eventLogs.push('hook'),
});

return <button ref={buttonRef} listeners={listener} />;
return <button ref={buttonRef} DEPRECATED_flareListeners={listener} />;
};

ReactDOM.render(<Test />, container);
Expand All @@ -838,7 +842,7 @@ describe('DOMEventResponderSystem', () => {
onFoo: e => eventLogs.push('hook'),
});

return <button ref={buttonRef} listeners={listener} />;
return <button ref={buttonRef} DEPRECATED_flareListeners={listener} />;
};

ReactDOM.render(<Test2 />, container);
Expand All @@ -859,7 +863,7 @@ describe('DOMEventResponderSystem', () => {
const listener = React.unstable_useResponder(TestResponder, {counter});
Scheduler.unstable_yieldValue('Test');
return (
<button listeners={listener} ref={ref}>
<button DEPRECATED_flareListeners={listener} ref={ref}>
Press me
</button>
);
Expand Down Expand Up @@ -927,7 +931,7 @@ describe('DOMEventResponderSystem', () => {
const listener = React.unstable_useResponder(TestResponder, {
onClick: logEvent,
});
return <button ref={ref} listeners={listener} />;
return <button ref={ref} DEPRECATED_flareListeners={listener} />;
};
ReactDOM.render(<Component />, container);
dispatchClickEvent(ref.current);
Expand Down Expand Up @@ -970,7 +974,7 @@ describe('DOMEventResponderSystem', () => {
const Component = () => {
const listener = React.unstable_useResponder(TestResponder, {});
return (
<div listeners={listener}>
<div DEPRECATED_flareListeners={listener}>
{ReactDOM.createPortal(<button ref={buttonRef} />, domNode)}
</div>
);
Expand All @@ -994,7 +998,7 @@ describe('DOMEventResponderSystem', () => {
const Component = () => {
const listener = React.unstable_useResponder(TestResponder, {});
return (
<div listeners={listener}>
<div DEPRECATED_flareListeners={listener}>
{ReactDOM.createPortal(<button ref={buttonRef} />, domNode)}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ function createOpenTagMarkup(
if (!hasOwnProperty.call(props, propKey)) {
continue;
}
if (enableFlareAPI && propKey === 'listeners') {
if (enableFlareAPI && propKey === 'DEPRECATED_flareListeners') {
continue;
}
let propValue = props[propKey];
Expand Down
10 changes: 8 additions & 2 deletions packages/react-dom/src/shared/DOMProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import warning from 'shared/warning';
import {enableFlareAPI} from 'shared/ReactFeatureFlags';

type PropertyType = 0 | 1 | 2 | 3 | 4 | 5 | 6;

Expand Down Expand Up @@ -207,7 +208,7 @@ function PropertyInfoRecord(
const properties = {};

// These props are reserved by React. They shouldn't be written to the DOM.
[
const reservedProps = [
'children',
'dangerouslySetInnerHTML',
// TODO: This prevents the assignment of defaultValue to regular
Expand All @@ -219,7 +220,12 @@ const properties = {};
'suppressContentEditableWarning',
'suppressHydrationWarning',
'style',
].forEach(name => {
];
if (enableFlareAPI) {
reservedProps.push('DEPRECATED_flareListeners');
}

reservedProps.forEach(name => {
properties[name] = new PropertyInfoRecord(
name,
RESERVED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (__DEV__) {
props.readOnly ||
props.disabled ||
props[propName] == null ||
(enableFlareAPI && props.listeners)
(enableFlareAPI && props.DEPRECATED_flareListeners)
) {
return null;
}
Expand All @@ -53,7 +53,7 @@ if (__DEV__) {
props.readOnly ||
props.disabled ||
props[propName] == null ||
(enableFlareAPI && props.listeners)
(enableFlareAPI && props.DEPRECATED_flareListeners)
) {
return null;
}
Expand Down
Loading

0 comments on commit 73a412e

Please sign in to comment.