Skip to content

Commit

Permalink
Fix updateSlot missing from default SlotFillContext (#23108)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegohaz authored Jun 13, 2020
1 parent 830651a commit b30b0d4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const SlotFillContext = createContext( {
slots: {},
fills: {},
registerSlot: () => {},
updateSlot: () => {},
unregisterSlot: () => {},
registerFill: () => {},
unregisterFill: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function useSlotRegistry() {
slots,
fills,
registerSlot,
updateSlot,
unregisterSlot,
registerFill,
unregisterFill,
Expand Down
14 changes: 14 additions & 0 deletions packages/components/src/slot-fill/test/__snapshots__/slot.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Slot bubblesVirtually false should not break without a Provider 1`] = `
<div>
<div />
</div>
`;

exports[`Slot bubblesVirtually false should subsume another slot by the same name 1`] = `
<div>
<div
Expand Down Expand Up @@ -37,6 +43,14 @@ exports[`Slot bubblesVirtually false should unmount two slots with the same name
</div>
`;

exports[`Slot bubblesVirtually true should not break without a Provider 1`] = `
<div>
<div>
<div />
</div>
</div>
`;

exports[`Slot bubblesVirtually true should subsume another slot by the same name 1`] = `
<div>
<div
Expand Down
16 changes: 16 additions & 0 deletions packages/components/src/slot-fill/test/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,22 @@ describe( 'Slot', () => {
);
expect( container ).toMatchSnapshot();
} );

it( 'should not break without a Provider', () => {
const { container } = render(
<>
<div>
<Slot
name="chicken"
bubblesVirtually={ bubblesVirtually }
/>
</div>
<Fill name="chicken" />
</>
);

expect( container ).toMatchSnapshot();
} );
}
);
} );

0 comments on commit b30b0d4

Please sign in to comment.