Skip to content

Commit

Permalink
Interactivity API: Remove data-wp-slot and data-wp-fill (#57854)
Browse files Browse the repository at this point in the history
* Remove slot and fill directives

* Remove slots tests

* Update changelog
  • Loading branch information
cbravobernal authored Jan 16, 2024
1 parent b8c177d commit f6d29bd
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 387 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions packages/interactivity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Add the `data-wp-run` directive along with the `useInit` and `useWatch` hooks. ([57805](https://github.com/WordPress/gutenberg/pull/57805))

### Breaking Change

- Remove `data-wp-slot` and `data-wp-fill`. ([#57854](https://github.com/WordPress/gutenberg/pull/57854))

### Bug Fix

- Fix namespaces when there are nested interactive regions. ([#57029](https://github.com/WordPress/gutenberg/pull/57029))
Expand Down
59 changes: 0 additions & 59 deletions packages/interactivity/src/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { deepSignal, peek } from 'deepsignal';
import { createPortal } from './portals';
import { useWatch, useInit } from './utils';
import { directive } from './hooks';
import { SlotProvider, Slot, Fill } from './slots';
import { navigate } from './router';

const isObject = ( item ) =>
Expand Down Expand Up @@ -333,64 +332,6 @@ export default () => {
element.props.children = evaluate( entry );
} );

// data-wp-slot
directive(
'slot',
( { directives: { slot }, props: { children }, element } ) => {
const { value } = slot.find(
( { suffix } ) => suffix === 'default'
);
const name = typeof value === 'string' ? value : value.name;
const position = value.position || 'children';

if ( position === 'before' ) {
return (
<>
<Slot name={ name } />
{ children }
</>
);
}
if ( position === 'after' ) {
return (
<>
{ children }
<Slot name={ name } />
</>
);
}
if ( position === 'replace' ) {
return <Slot name={ name }>{ children }</Slot>;
}
if ( position === 'children' ) {
element.props.children = (
<Slot name={ name }>{ element.props.children }</Slot>
);
}
},
{ priority: 4 }
);

// data-wp-fill
directive(
'fill',
( { directives: { fill }, props: { children }, evaluate } ) => {
const entry = fill.find( ( { suffix } ) => suffix === 'default' );
const slot = evaluate( entry );
return <Fill slot={ slot }>{ children }</Fill>;
},
{ priority: 4 }
);

// data-wp-slot-provider
directive(
'slot-provider',
( { props: { children } } ) => (
<SlotProvider>{ children }</SlotProvider>
),
{ priority: 4 }
);

// data-wp-run
directive( 'run', ( { directives: { run }, evaluate } ) => {
run.forEach( ( entry ) => evaluate( entry ) );
Expand Down
38 changes: 0 additions & 38 deletions packages/interactivity/src/slots.js

This file was deleted.

Loading

0 comments on commit f6d29bd

Please sign in to comment.