Skip to content

Commit

Permalink
Revert "Ensure stores exist for vdom namespaces"
Browse files Browse the repository at this point in the history
This reverts commit 17953d9.
  • Loading branch information
sirreal committed Mar 14, 2024
1 parent 17953d9 commit 813274c
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions packages/interactivity/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { hydrate } from 'preact';
import { toVdom, hydratedIslands } from './vdom';
import { createRootFragment } from './utils';
import { directivePrefix } from './constants';
import { store, stores, universalUnlock } from './store';

// Keep the same root fragment for each interactive region node.
const regionRootFragments = new WeakMap();
Expand All @@ -34,29 +33,10 @@ export const initialVdom = new WeakMap();

// Initialize the router with the initial DOM.
export const init = async () => {
/** @type { NodeListOf<HTMLElement>} */
const nodes = document.querySelectorAll(
`[data-${ directivePrefix }-interactive]`
);

for ( const node of nodes ) {
// Before initializing the vdom, make sure a store exists for the namespace.
// This ensures that directives can subscribe to the store even if it has
// not yet been created on the client so that directives can be updated when
// stores are later created.
let namespace = /** @type {HTMLElement} */ ( node ).dataset[
`${ directivePrefix }Interactive`
];
try {
namespace = JSON.parse( namespace ).namespace;
} catch {}
if ( ! stores.has( namespace ) ) {
store( namespace, undefined, {
lock: universalUnlock,
} );
}
}

for ( const node of nodes ) {
if ( ! hydratedIslands.has( node ) ) {
await yieldToMain();
Expand Down

0 comments on commit 813274c

Please sign in to comment.