FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
project logo
Teddy2100EnhancedVNode
Public
Like
EnhancedVNode
Home
Code
3
README.md
logo.svg
S
vnode.js
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data โ€“ all from the browser, and deployed in miliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
โ€ฆ
README.md

EnhancedVNode

A minimalist, plugin-ready hyperscript-style utility for rendering elements with style normalization, class processing, and custom behavioral plugins. Compatible with React, Preact, or any functionally similar createElement.

โœจ Features

  • ๐Ÿงฑ Lightweight functional interface: const h = new EnhancedVNode(createElement)
  • ๐ŸŽจ Normalizes class strings into Set and filters empty entries
  • ๐ŸŽ›๏ธ Parses inline style into clean JS objects
  • ๐Ÿงฉ Plugin system for custom props, dynamic logic, or design tokens
  • ๐ŸŽฏ Renderer-agnostic: bring your own createElement

๐Ÿ“ฆ Installation

This utility is framework-neutral. Just copy the source file into your project and wire it up:

Create val
import { createElement } from "preact"; // or import from react import EnhancedVNode from "./EnhancedVNode.js"; const h = new EnhancedVNode(createElement);

๐Ÿ› ๏ธ Usage

Create val
h.plugin(props => { if (props.bg) { props.classList.add(`bg-${props.bg}`); delete props.bg; } }); const vnode = h("div", { class: "box padded", style: "color: red; padding: 1rem;", bg: "blue" });

The resulting vnode will have:

  • Normalized class string: "box padded bg-blue"
  • Inlined style converted into a class (via GooberJS)
  • Plugins applied and props cleaned up

๐Ÿ”Œ Plugins

Plugins are just functions that receive and mutate the props object before rendering:

Create val
h.plugin(props => { if (props.opacity) { props.styleObject.opacity = parseFloat(props.opacity); delete props.opacity; } });

You can add as many as you'd like. They run sequentially.

๐Ÿ” Utilities

Create val
h.toStyleObject("color: red; padding: 1rem;") // โžœ { color: "red", padding: "1rem" }

๐Ÿงช Example Setup

Create val
import { createElement } from "preact"; import EnhancedVNode from "./EnhancedVNode.js"; const h = new EnhancedNVode(createElement); h.plugin(props => { if (props.rounded) { props.classList.add("rounded"); delete props.rounded; } }); export default h;

๐Ÿง  Philosophy

This utility embraces composability, readability, and framework flexibility. By abstracting common patterns around class and style handling, EnhancedVNode helps you build declarative UIs without tying you to one ecosystem.

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
ยฉ 2025 Val Town, Inc.