Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #217 from WordPress/remove-components
Browse files Browse the repository at this point in the history
Remove components and everything related to them
  • Loading branch information
luisherranz authored Apr 21, 2023
2 parents 7e355e6 + 2c1a70a commit 855c1e5
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 43 deletions.
22 changes: 0 additions & 22 deletions src/runtime/components.js

This file was deleted.

1 change: 0 additions & 1 deletion src/runtime/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export const csnMetaTagItemprop = 'wp-client-side-navigation';
export const componentPrefix = 'wp-';
export const directivePrefix = 'data-wp-';
19 changes: 1 addition & 18 deletions src/runtime/hooks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { h, options, createContext } from 'preact';
import { useRef } from 'preact/hooks';
import { rawStore as store } from './store';
import { componentPrefix } from './constants';

// Main context.
const context = createContext({});
Expand All @@ -12,12 +11,6 @@ export const directive = (name, cb) => {
directiveMap[name] = cb;
};

// WordPress Components.
const componentMap = {};
export const component = (name, Comp) => {
componentMap[name] = Comp;
};

// Resolve the path to some property of the store object.
const resolve = (path, ctx) => {
// If path starts with !, remove it and save a flag.
Expand Down Expand Up @@ -60,19 +53,9 @@ const Directive = ({ type, directives, props: originalProps }) => {
// Preact Options Hook called each time a vnode is created.
const old = options.vnode;
options.vnode = (vnode) => {
const type = vnode.type;
const { directives } = vnode.props;

if (
typeof type === 'string' &&
type.slice(0, componentPrefix.length) === componentPrefix
) {
vnode.props.children = h(
componentMap[type.slice(componentPrefix.length)],
{ ...vnode.props, context, evaluate: getEvaluate() },
vnode.props.children
);
} else if (directives) {
if (directives) {
const props = vnode.props;
delete props.directives;
if (!props._wrapped) {
Expand Down
2 changes: 0 additions & 2 deletions src/runtime/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import registerDirectives from './directives';
import registerComponents from './components';
import { init } from './router';
export { store } from './store';
export { navigate } from './router';
Expand All @@ -9,7 +8,6 @@ export { navigate } from './router';
*/
document.addEventListener('DOMContentLoaded', async () => {
registerDirectives();
registerComponents();
await init();
// eslint-disable-next-line no-console
console.log('Interactivity API started');
Expand Down

0 comments on commit 855c1e5

Please sign in to comment.