Skip to content

Commit

Permalink
Fix interactivity
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 15, 2024
1 parent 1737a67 commit 2713e68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
4 changes: 2 additions & 2 deletions packages/dependency-extraction-webpack-plugin/lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ function defaultRequestToExternalModule( request ) {
const isWordPressScript = Boolean( defaultRequestToExternal( request ) );

if ( isWordPressScript ) {
/*throw new Error(
throw new Error(
`Attempted to use WordPress script in a module: ${ request }, which is not supported yet.`
);*/
);
}
}

Expand Down
23 changes: 11 additions & 12 deletions packages/interactivity/src/directives.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/**
* External dependencies
*/
import { type RefObject } from 'preact';
import { h as createElement, type RefObject } from 'preact';
import { useContext, useMemo, useRef } from 'preact/hooks';
import { deepSignal, peek, type DeepSignal } from 'deepsignal';

Expand Down Expand Up @@ -231,6 +231,7 @@ export default () => {
// data-wp-context
directive(
'context',
// @ts-ignore-next-line
( {
directives: { context },
props: { children },
Expand Down Expand Up @@ -260,7 +261,7 @@ export default () => {
return proxifyContext( currentValue.current, inheritedValue );
}, [ defaultEntry, inheritedValue ] );

return <Provider value={ contextStack }>{ children }</Provider>;
return createElement( Provider, { value: contextStack }, children );
},
{ priority: 5 }
);
Expand Down Expand Up @@ -481,12 +482,10 @@ export default () => {
} ) => {
// Preserve the initial inner HTML.
const cached = useMemo( () => innerHTML, [] );
return (
<Type
dangerouslySetInnerHTML={ { __html: cached } }
{ ...rest }
/>
);
return createElement( Type, {
dangerouslySetInnerHTML: { __html: cached },
...rest,
} );
}
);

Expand Down Expand Up @@ -549,10 +548,10 @@ export default () => {
? getEvaluate( { scope } )( eachKey[ 0 ] )
: item;

return (
<Provider value={ mergedContext } key={ key }>
{ element.props.content }
</Provider>
return createElement(
Provider,
{ value: mergedContext, key },
element.props.content
);
} );
},
Expand Down
20 changes: 9 additions & 11 deletions packages/interactivity/src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,15 @@ const Directives = ( {

// Recursively render the wrapper for the next priority level.
const children =
nextPriorityLevels.length > 0 ? (
<Directives
directives={ directives }
priorityLevels={ nextPriorityLevels }
element={ element }
originalProps={ originalProps }
previousScope={ scope }
/>
) : (
element
);
nextPriorityLevels.length > 0
? createElement( Directives, {
directives,
priorityLevels: nextPriorityLevels,
element,
originalProps,
previousScope: scope,
} )
: element;

const props = { ...originalProps, children };
const directiveArgs = {
Expand Down

0 comments on commit 2713e68

Please sign in to comment.