I have created a custom SolidJS renderer that returns JSON but the JSX tags that are being called always return HTML elements.
export const renderer = createRenderer<ElementComponent>({
createElement(type) {
console.log('createElement');
return { type: type as ElementComponent['type'], children: [] };
},
createTextNode(children: string) {
console.log('createTextNode');
return { type: 'text', children };
},
replaceText(textNode: ElementText, value: string) {
console.log('replaceText');
textNode.children = value;
},
isTextNode(node) {
console.log('isTextNode');
return node.type === 'text';
},
setProperty<T>(
node: ElementComponent,
name: keyof ElementComponent,
value: T,
) {
console.log('setProp', node, value);
// node[name] = value;
},
insertNode(parent, node): void {
if (parent.type !== 'text') {
parent.children?.push(node);
}
console.log('insertNode', node);
},
removeNode(parent, node): void {
if (parent.type !== 'text') {
const index = parent.children.indexOf(node);
parent.children?.splice(index, 1);
}
},
getParentNode(node: unknown): unknown {
throw new Error('Function not implemented.');
},
getFirstChild(node): unknown {
throw new Error('Function not implemented.');
},
getNextSibling(node: unknown): unknown {
throw new Error('Function not implemented.');
},
});
const view: ElementView = { type: 'view', children: [] };
const MyComponent = () => {
return <myview><mytext>Hello world</mytext></myview>
}
renderer.render(MyComponent, view);
console.log(view);
When I console log the view, the myview and mytext are returned as HTML elements instead of JSON objects. How can I make it so that these elements are returned as plain JSON objects, not HTML elements.