Skip to content
Closed
Changes from all commits
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
23 changes: 13 additions & 10 deletions packages/interactivity/src/vdom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,24 @@ export function toVdom( root ) {
}

if ( directives.length ) {
// Reduce the directives array to build the __directives object.
props.__directives = directives.reduce(
( obj, [ name, ns, value ] ) => {
const directiveMatch = directiveParser.exec( name );
( obj, [ directiveName, namespace, inputValue ] ) => {
const directiveMatch =
directiveParser.exec( directiveName );
if ( directiveMatch === null ) {
warn( `Invalid directive: ${ name }.` );
return obj;
}
const prefix = directiveMatch[ 1 ] || '';
const suffix = directiveMatch[ 2 ] || 'default';

obj[ prefix ] = obj[ prefix ] || [];
obj[ prefix ].push( {
namespace: ns ?? currentNamespace(),
value,
suffix,

const directive = directiveMatch[ 1 ] || '';
const directiveEvent = directiveMatch[ 2 ] || 'default';

obj[ directive ] = obj[ directive ] || [];
obj[ directive ].push( {
namespace: namespace ?? currentNamespace(),
input: inputValue,
directiveEvent,
} );
return obj;
},
Expand Down