Skip to content

Remove snabbdom dependency with minimal pure DOM implementation - #21

Draft
irony with Copilot wants to merge 4 commits into
masterfrom
copilot/remove-snabbdom-dependency
Draft

Remove snabbdom dependency with minimal pure DOM implementation#21
irony with Copilot wants to merge 4 commits into
masterfrom
copilot/remove-snabbdom-dependency

Conversation

Copilot AI commented Nov 16, 2025

Copy link
Copy Markdown

Replaces snabbdom with a lightweight (~245 LOC) pure JavaScript DOM manipulation layer. Zero runtime dependencies.

Changes

src/render.mjs - Complete rewrite

  • Custom createElement() for DOM creation from virtual nodes
  • Diffing/patching via updateElement(), updateAttributes(), updateProperties(), updateStyles()
  • Preserves existing API: render(tree, node, oldTree) signature unchanged

package.json

  • Removed snabbdom: 3.5.1 dependency
  • Bundle size: 6KB → 4.3KB (28% smaller)

README.md

  • Updated to reflect zero dependencies

Implementation

The new implementation handles all snabbdom features used by pureact:

// Creates real DOM from virtual nodes
function createElement(vnode) {
  if (typeof vnode === 'string' || typeof vnode === 'number') {
    return document.createTextNode(String(vnode))
  }
  
  const el = document.createElement(vnode.tagName)
  
  // Handles attrs, props (including event listeners), styles
  // Recursively creates children
  // ...
}

// Efficient diffing and patching
function updateElement(parent, newNode, oldNode, index) {
  // Handles additions, removals, replacements, updates
  // Updates attrs/props/styles only when changed
  // Recursively diffs children
  // ...
}

Supports:

  • Event listeners (onclick, etc.)
  • Properties (className, value, checked)
  • Attributes and styles
  • Text and element nodes
  • Nested children

Demo

Working counter demo

Interactive counter showing component rendering, store integration, and event handling working correctly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/142.0.7444.162/linux64/chrome-linux64.zip
    • Triggering command: node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Try to remove the dependency to snabbdom by implementing the basic dom manipulating techniques in the same style as the rest of the codebase, minimal and pure


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel

vercel Bot commented Nov 16, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
pureact-todo Error Error Nov 16, 2025 3:27pm

Co-authored-by: irony <395843+irony@users.noreply.github.com>
Co-authored-by: irony <395843+irony@users.noreply.github.com>
Co-authored-by: irony <395843+irony@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove dependency on snabbdom for DOM manipulation Remove snabbdom dependency with minimal pure DOM implementation Nov 16, 2025
Copilot AI requested a review from irony November 16, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants