Skip to content
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

Experimental event API: loosen EventTarget constraints and warnings #15292

Merged
merged 2 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,6 @@ export function getChildHostContextForEvent(
isEventTarget: false,
};
} else if (type === REACT_EVENT_TARGET_TYPE) {
warning(
parentHostContextDev.eventData !== null &&
parentHostContextDev.eventData.isEventComponent,
'validateDOMNesting: React event targets must be direct children of event components.',
);
eventData = {
isEventComponent: false,
isEventTarget: true,
Expand Down
4 changes: 0 additions & 4 deletions packages/react-noop-renderer/src/createReactNoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
);
return EVENT_COMPONENT_CONTEXT;
} else if (type === REACT_EVENT_TARGET_TYPE) {
warning(
parentHostContext === EVENT_COMPONENT_CONTEXT,
'validateDOMNesting: React event targets must be direct children of event components.',
);
return EVENT_TARGET_CONTEXT;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,25 +184,6 @@ describe('ReactFiberEvents', () => {
);
});

it('should warn if an event target is not a direct child of an event component', () => {
const Test = () => (
<EventComponent>
<div>
<EventTarget>
<span>Child 1</span>
</EventTarget>
</div>
</EventComponent>
);

expect(() => {
ReactNoop.render(<Test />);
expect(Scheduler).toFlushWithoutYielding();
}).toWarnDev(
'Warning: validateDOMNesting: React event targets must be direct children of event components.',
);
});

it('should warn if an event target has an event component as a child', () => {
const Test = () => (
<EventComponent>
Expand Down Expand Up @@ -552,26 +533,6 @@ describe('ReactFiberEvents', () => {
expect(root).toMatchRenderedOutput(<span>Child 1</span>);
});

it('should warn if an event target is not a direct child of an event component', () => {
const Test = () => (
<EventComponent>
<div>
<EventTarget>
<span>Child 1</span>
</EventTarget>
</div>
</EventComponent>
);

const root = ReactTestRenderer.create(null);
expect(() => {
root.update(<Test />);
expect(Scheduler).toFlushWithoutYielding();
}).toWarnDev(
'Warning: validateDOMNesting: React event targets must be direct children of event components.',
);
});

it('should warn if an event target has an event component as a child', () => {
const Test = () => (
<EventComponent>
Expand Down Expand Up @@ -923,26 +884,6 @@ describe('ReactFiberEvents', () => {
expect(container.innerHTML).toBe('<span>Child 1</span>');
});

it('should warn if an event target is not a direct child of an event component', () => {
const Test = () => (
<EventComponent>
<div>
<EventTarget>
<span>Child 1</span>
</EventTarget>
</div>
</EventComponent>
);

expect(() => {
const container = document.createElement('div');
ReactDOM.render(<Test />, container);
expect(Scheduler).toFlushWithoutYielding();
}).toWarnDev(
'Warning: validateDOMNesting: React event targets must be direct children of event components.',
);
});

it('should warn if an event target has an event component as a child', () => {
const Test = () => (
<EventComponent>
Expand Down
4 changes: 0 additions & 4 deletions packages/react-test-renderer/src/ReactTestHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ export function getChildHostContextForEvent(
);
return EVENT_COMPONENT_CONTEXT;
} else if (type === REACT_EVENT_TARGET_TYPE) {
warning(
parentHostContext === EVENT_COMPONENT_CONTEXT,
'validateDOMNesting: React event targets must be direct children of event components.',
);
return EVENT_TARGET_CONTEXT;
}
}
Expand Down