WildflowerJS Reactive JS, No BS*

A no-build reactive JavaScript framework, rooted in the web platform.
No build step. No dependencies. No lock-in.

<script src="wildflower.min.js"></script> ...and start building.

Back to Basics

The code you write is 100% web standard code. HTML stays HTML. JavaScript stays JavaScript. CSS stays CSS. No JSX, no templating language, no custom syntax to learn. If you know the web platform, you already know how to use this.

WildflowerJS extends the web platform. It doesn't replace it.

Your Development Simplified

Because you develop with 100% web standards, every tool in your existing chain already understands the code: IDE, browser DevTools, linter, formatter, screen reader, SEO crawler. Nothing to install, no custom file types, no sourcemaps. Save the file, refresh, and your change is live.

Just be a web developer.

Batteries Included: One Mental Model

Router, SSR, stores, computed properties, two-way binding, event modifiers, data pools, and TypeScript types, all built in, all speaking the same language. Learn data-bind once and you know binding everywhere: lists, pools, stores, forms. There's no five-library stack to keep in sync.

One script tag. Everything you need.

<div data-component="counter">
  <span data-bind="count"></span>
  <button data-action="increment">
    +1
  </button>
</div>

<script>
wildflower.component('counter', {
  state: { count: 0 },
  increment() { this.count++ }
})
</script>

How It Works

data-bind connects state to the DOM.

data-action connects events to methods.

this.count++ triggers a precise DOM update.

Mutate state. The DOM updates.

Two Reactivity Modes

data-list for automatic reactivity: mutate state, DOM updates. data-pool for explicit control: plain objects, zero proxy overhead, you say what changed.

Same template syntax. Different performance profile. From interactive forms to per-frame particle systems. You choose the right tradeoff for the job.

Try it. Right-click, inspect this demo. Every dot is a real DOM element.

See full demo →

* Build Step

Zero Toolchain

Modern frameworks ask you to install a compiler, a bundler, a package manager, hundreds of fragile transitive dependencies, and a framework-specific file format, before you write a single line of your application.

WildflowerJS was built starting from a single principle: no build step, no tooling. Ever.

WildflowerJS asks you to add a script tag.

There's no CLI scaffolding step, no config files, no .vue/.jsx/.svelte source format. You don't debug through sourcemaps or wait on a build pipeline. Your project has zero dependencies.

Performance isn't a tradeoff. Build steps optimize bundle delivery, not the runtime work that follows it. WildflowerJS writes directly to the DOM, with no virtual DOM or reconciliation pass between state change and update, so it doesn't need a build step to be fast.

The framework is full-featured without the toolchain: router, SSR, stores, computed properties, transitions, pools. You don't need a toolchain to use any of it.

my-app/
  index.html
  app.js
  style.css
  wildflower.min.js

That's the entire project. No package.json.
No node_modules. No config files. Ship it.

Zero Install. Zero Attack Surface.

Every dependency you install is trust extended to a maintainer you've never met, running scripts on your dev machine and in your CI. A typical React + Vite + UI‑lib setup pulls in 300+ transitive packages before you write a feature.

Each one is a potential intrusion vector. NPM worms, OAuth chains compromising deploy platforms, postinstall hijacking: the supply chain is now where production code gets compromised, not the deploy. And signing isn't a backstop: Mini Shai‑Hulud (May 2026) compromised 170+ packages whose malicious versions carried valid SLSA Build Level 3 provenance, because the attestation came from build infrastructure the worm had already taken over.

WildflowerJS users don't have this attack surface, by construction. There is no npm install, no postinstall script, no transitive package graph. The framework is one file you copy or pin by hash.

As of v1.1, the same holds for building the framework itself. WildflowerJS bundles with a vendored rollup and terser pipeline pulled as three SHA‑512‑pinned tarballs: no npm install, no transitive packages, no postinstall scripts in the build path. The entire toolchain is three files you verify by hash.

Zero dependencies is the absence of a problem the rest of the industry has not properly addressed.

A typical React/Vue project:

  npm install
  ├── hundreds of packages
  ├── from hundreds of maintainers
  ├── postinstall scripts run on install
  └── tens to hundreds of MB of transitive code

WildflowerJS:

  <script src="wildflower.min.js"></script>
  └── 1 file.
      No transitive dependencies.

Zero Lock-in

WildflowerJS works with the DOM, not instead of it. There's no virtual DOM intercepting your code and no compiler rewriting your markup. The render cycle is yours.

That means Leaflet, DataTables, Chart.js, D3, Three.js, any library that touches the DOM, just works. No wrapper packages or framework-specific escape hatches required. Drop in a script tag and use it.

Because your code is standard HTML and JavaScript, you're never locked in. Your skills transfer and your code is more portable. If you outgrow the framework, your knowledge doesn't expire.

This also means your "ecosystem" is all of the world of vanilla JS. Without compromises or hacks.

<!-- Use any library directly -->
<div data-component="map-view">
  <div id="map" style="height: 400px"></div>
</div>
wildflower.component('map-view', {
  state: { lat: 51.505, lng: -0.09 },
  init() {
    // Leaflet works as-is. No wrappers.
    this._map = L.map('map')
      .setView([this.lat, this.lng], 13);
    L.tileLayer('https://{s}.tile.osm.org'
      + '/{z}/{x}/{y}.png').addTo(this._map);
  }
})

Precise Reactivity

When you write this.count++, WildflowerJS updates the single DOM node bound to count. Nothing else is touched. There's no tree diffing or reconciliation pass to figure that out.

This isn't a tradeoff. You get fine-grained updates and a simple mental model. Change a property, the bound element updates. That's the entire reactivity model.

Other frameworks ask you to learn signals, accessors, memos, effects, and subscription lifecycles to achieve what WildflowerJS does with a property assignment.

wildflower.component('dashboard', {
  state: {
    users: 1420,
    status: 'healthy'
  },
  computed: {
    summary() {
      return this.users + ' users, ' + this.status;
    }
  },
  refresh() {
    this.users = 1421;
    // Only the elements bound to 'users'
    // and 'summary' update. Everything
    // else on the page is untouched.
  }
})

One Reactivity Model. Everywhere.

Components, Stores, and Plugins all share the same reactive foundation. State, computed properties, and methods work identically no matter where they live. Learn it once, it works the same way in a UI component, a global store, or a framework plugin.

Other frameworks make you learn a different system for each layer. React components use hooks, but stores need Redux or Zustand, which are completely different APIs. Vue components use reactive data, but Pinia stores have their own patterns. Every layer is a new mental model.

In WildflowerJS, there's one model. A store is a component without a template. A plugin is an entity that extends the framework itself, adding directives, lifecycle hooks, and services. The same this.count++ triggers the same reactivity everywhere.

This unlocks patterns other frameworks can't express. A store can run headless physics simulations with tick(), feeding data into a component that renders it through a pool, all using the same reactive primitives, no glue code required.

// Component: reactive UI
wildflower.component('cart', {
  state: { items: [] },
  computed: {
    total() { return this.items.length; }
  }
})

// Store: global shared state
wildflower.store('user', {
  state: { name: '', role: 'guest' },
  computed: {
    isAdmin() { return this.role === 'admin'; }
  }
})

// Plugin: extends the framework
wildflower.plugin({
  name: 'notifications',
  state: { items: [], unreadCount: 0 },
  computed: {
    hasUnread() { return this.unreadCount > 0; }
  },
  add(msg) { this.items.push(msg); this.unreadCount++; }
})
// Access globally: wildflower.$notifications.add(...)

// Same state. Same computed. Same methods.

Data Pools

Every framework wraps collection items in reactive proxies, whether the item needs it or not. WildflowerJS gives you a choice: data-list for push reactivity (automatic), data-pool for pull reactivity (explicit control, zero proxy overhead).

Pools render plain objects with the same template syntax as lists. Mutate the object, call markDirty(), and only that item updates. Full CRUD, selection, bulk operations, all faster than the push-reactive path.

And because pools use pull-based rendering, they scale to simulations, games, particle systems, and data visualizations at native frame rate. Use cases that would choke a virtual DOM. No other framework has anything like this.

<div data-component="user-table">
  <tbody data-pool="users" data-key="id">
    <template>
      <tr>
        <td data-bind="name"></td>
        <td data-bind="status"
            data-bind-class="status === 'active'
              ? 'badge success'
              : 'badge inactive'"></td>
      </tr>
    </template>
  </tbody>
</div>
wildflower.component('user-table', {
  pools: { users: {} },

  init() {
    // Populate: plain objects, no proxies
    data.forEach(u => this.pools.users.add(u));
  },

  // Optional: add tick() and the same pool
  // renders every frame. Same template, same
  // data, different rendering frequency.
  // That's the only difference between a
  // display table and a particle system.
})

Built for AI-Assisted Development

Because WildflowerJS is standard HTML and JavaScript, AI code assistants already know how to write it. There's no custom syntax to hallucinate or compiler quirks to work around. The code an AI generates runs exactly as written, with no build step between generation and execution.

We go further. WildflowerJS ships an AI-optimized reference page with patterns, anti-patterns, and examples designed for code generation context windows. Our llms.txt file follows the llms.txt convention for machine-readable documentation.

And for structured app generation, our Universal App Manifest lets you describe an entire application as a JSON schema (components, state, computed properties, methods, templates) and have an AI generate the working code from the manifest, mediated through framework-specific idiom files.

You: "Build me a todo app with
WildflowerJS"

AI reads llms.txt or ai-assistant.html
     ↓
Generates standard HTML + JS
     ↓
<div data-component="todo-app">
  <input data-model="newItem">
  <button data-action="addItem">
    Add
  </button>
  <ul data-list="items">
    <template>
      <li data-bind="text"></li>
    </template>
  </ul>
</div>
     ↓
Open in your browser. It works, and you can read and understand the code.

Event Handling

WildflowerJS binds DOM events to component methods through data-action attributes, providing a clean separation between markup and behavior.

💡 Key Concept: WildflowerJS uses the data-action attribute to bind DOM events to component methods, providing a clean separation between markup and behavior.

Basic Event Handling

Use data-action to bind events to component methods:

<div data-component="interactive-events-demo">
    <div class="row">
        <div class="col-md-4">
            <h5>Click Events</h5>
            <button data-action="handleClick" class="btn btn-primary mb-2">
                Click Me
            </button>
            <p><strong>Clicked:</strong> <span data-bind="clickCount" class="badge bg-primary"></span> times</p>
            <button data-action="dblclick:doubleClick" class="btn btn-success btn-sm">
                Double-Click Me
            </button>
        </div>
        
        <div class="col-md-4">
            <h5>Input Events</h5>
            <input type="text" 
                   data-action="input:handleInputChange keyup:handleKeyup" 
                   data-model="inputValue" 
                   placeholder="Type something..." 
                   class="form-control mb-2">
            <p><strong>Value:</strong> <em data-bind="inputValue"></em></p>
            <p><strong>Length:</strong> <span data-bind="inputLength"></span> chars</p>
            <p><strong>Last Key:</strong> <code data-bind="lastKey"></code></p>
        </div>
        
        <div class="col-md-4">
            <h5>Mouse Events</h5>
            <button data-action="mouseenter:handleHover mouseleave:handleHoverOut"
                    class="btn btn-secondary mb-2">
                Hover Me
            </button>
            <p data-bind="hoverStatus"></p>
            <div data-action="mousedown:handleMouseDown mouseup:handleMouseUp" 
                 class="border rounded p-2 bg-light text-center" 
                 style="height: 60px; cursor: pointer;">
                Mouse Area
                <div class="small"><span data-bind="mouseStatus"></span></div>
            </div>
        </div>
    </div>
    
    <div class="mt-4">
        <h5>Event Log</h5>
        <div class="d-flex justify-content-between mb-2">
            <span>Recent events (<span data-bind="eventCount"></span>):</span>
            <button data-action="clearEventLog" class="btn btn-sm btn-secondary">
                Clear Log
            </button>
        </div>
        <div class="border rounded p-2" style="height: 120px; overflow-y: auto; font-family: monospace; font-size: 0.85em;">
            <div data-list="eventLog">
                <template>
                    <div class="small d-flex justify-content-between" 
                         data-bind-class="type === 'click' ? 'text-primary' : type === 'input' ? 'text-success' : 'text-info'">
                        <span><span data-bind="timestamp"></span> - <span data-bind="description"></span></span>
                        <span class="badge badge-sm" data-bind-class="badgeClass">
                            <span data-bind="type"></span>
                        </span>
                    </div>
                </template>
            </div>
        </div>
    </div>
</div>
wildflower.component('interactive-events-demo', {
    state: {
        clickCount: 0,
        inputValue: '',
        hoverStatus: 'Not hovering',
        mouseStatus: 'Ready',
        lastKey: 'none',
        eventLog: []
    },
    
    computed: {
        inputLength() {
            return this.inputValue.length
        },
        
        eventCount() {
            return this.eventLog.length
        },

        // Item-level computed for event log badges
        badgeClass() {
            const classes = {
                'click': 'bg-primary',
                'input': 'bg-success',
                'mouse': 'bg-info',
                'keyboard': 'bg-warning'
            }
            return classes[this.type] || 'bg-secondary'
        }
    },
    
    // Click event handlers
    handleClick(event, element) {
        this.clickCount++
        this.logEvent('Button clicked', 'click')
        console.log('Button clicked!', { event, element })
    },
    
    doubleClick(event, element) {
        this.clickCount += 2
        this.logEvent('Double click performed', 'click')
    },
    
    // Input event handlers
    handleInputChange(event, element) {
        this.logEvent(`Input changed: "${event.target.value}"`, 'input')
        console.log('Input changed:', event.target.value)
    },
    
    handleKeyup(event, element) {
        this.lastKey = event.key
        this.logEvent(`Key pressed: ${event.key}`, 'keyboard')
    },
    
    // Mouse event handlers
    handleHover(event, element) {
        this.hoverStatus = 'Currently hovering! 🙂'
        this.logEvent('Mouse hover started', 'mouse')
    },
    
    handleHoverOut(event, element) {
        this.hoverStatus = 'Not hovering'
        this.logEvent('Mouse hover ended', 'mouse')
    },
    
    handleMouseDown(event, element) {
        this.mouseStatus = 'Mouse Down 🔄'
        this.logEvent('Mouse down in area', 'mouse')
    },
    
    handleMouseUp(event, element) {
        this.mouseStatus = 'Mouse Up ⬆️'
        this.logEvent('Mouse up in area', 'mouse')
        
        // Reset after a short delay
        setTimeout(() => {
            this.mouseStatus = 'Ready'
        }, 1000)
    },
    
    // Utility methods
    logEvent(description, type) {
        this.eventLog.unshift({
            timestamp: new Date().toLocaleTimeString(),
            description: description,
            type: type
        })
        
        // Keep only last 15 events
        if (this.eventLog.length > 15) {
            this.eventLog = this.eventLog.slice(0, 15)
        }
    },
    
    clearEventLog() {
        this.eventLog = []
        this.logEvent('Event log cleared', 'click')
    }
})
Live Preview

Event Types and Syntax

WildflowerJS supports multiple event binding syntaxes:

Syntax Description Example
data-action="method" Default click event <button data-action="save">
data-action="event:method" Specific event type <input data-action="change:validate">
data-action="event1:method1 event2:method2" Multiple events <div data-action="mouseenter:show mouseout:hide">
data-action="method('arg1', 'arg2')" Method with arguments <button data-action="setStatus('active')">
<div data-component="event-types-demo">
    <div class="row">
        <div class="col-md-6">
            <h5>Form Events</h5>
            <form data-action="submit:handleSubmit">
                <div class="mb-2">
                    <input type="text"
                           data-action="focus:handleFocus blur:handleBlur"
                           placeholder="Focus/blur events"
                           class="form-control">
                </div>
                <div class="mb-2">
                    <select data-action="change:handleSelectChange" class="form-select">
                        <option value="">Select an option...</option>
                        <option value="option1">Form Option 1</option>
                        <option value="option2">Form Option 2</option>
                        <option value="option3">Form Option 3</option>
                    </select>
                </div>
                <button type="submit" class="btn btn-primary">Submit Form</button>
            </form>
        </div>
        
        <div class="col-md-6">
            <h5>Mouse Events</h5>
            <div data-action="mousedown:handleMouseDown mouseup:handleMouseUp mousemove:handleMouseMove" 
                 class="border p-3 text-center" 
                 style="height: 120px; cursor: crosshair; background-color: var(--card-bg);">
                <div>Mouse interaction area</div>
                <div class="small mt-2 text-muted">
                    Position: (<span data-bind="mouseX">0</span>, <span data-bind="mouseY">0</span>)
                </div>
                <div class="small text-muted">
                    Status: <span data-bind="mouseStatus">Ready</span>
                </div>
            </div>
        </div>
    </div>
    
    <div class="mt-4">
        <div class="d-flex justify-content-between align-items-center mb-2">
            <h5>Event Log (<span data-bind="eventCount"></span> events):</h5>
            <button data-action="clearEventLog" class="btn btn-sm btn-secondary">
                Clear Log
            </button>
        </div>
        <div class="border rounded p-2"
             style="height: 120px; overflow-y: auto; font-family: monospace; font-size: 0.8em; background-color: var(--card-bg);">
            <div data-list="eventLog">
                <template>
                    <div class="d-flex justify-content-between py-1 border-bottom">
                        <span><span data-bind="timestamp"></span> - <span data-bind="event"></span></span>
                        <small class="badge bg-secondary"><span data-bind="type"></span></small>
                    </div>
                </template>
            </div>
            <div data-show="isEmpty" class="text-center text-muted py-3">
                No events logged yet. Interact with the form and mouse area above.
            </div>
        </div>
    </div>
</div>
wildflower.component('event-types-demo', {
    state: {
        mouseX: 0,
        mouseY: 0,
        mouseStatus: 'Ready',
        eventLog: []
    },
    
    computed: {
        eventCount() {
            return this.eventLog.length
        },
        
        isEmpty() {
            return this.eventLog.length === 0
        }
    },
    
    // Form event handlers
    handleSubmit(event, element) {
        event.preventDefault()
        this.logEvent('Form submitted', 'form')

        // Get form data
        const formData = new FormData(element)
        const data = Object.fromEntries(formData.entries())
        console.log('Form submitted with data:', data)
    },
    
    handleFocus(event, element) {
        this.logEvent(`Input focused: ${element.placeholder}`, 'focus')
    },
    
    handleBlur(event, element) {
        const value = event.target.value
        this.logEvent(`Input blurred${value ? ': ' + value : ' (empty)'}`, 'blur')
    },
    
    handleSelectChange(event, element) {
        const value = event.target.value
        this.logEvent(`Select changed to: ${value || '(none)'}`, 'change')
    },
    
    // Mouse event handlers
    handleMouseDown(event, element) {
        this.mouseStatus = 'Mouse Down'
        this.logEvent('Mouse button pressed', 'mouse')
    },
    
    handleMouseUp(event, element) {
        this.mouseStatus = 'Mouse Up'
        this.logEvent('Mouse button released', 'mouse')
        
        // Reset status after delay
        setTimeout(() => {
            this.mouseStatus = 'Ready'
        }, 1000)
    },
    
    handleMouseMove(event, element) {
        const rect = element.getBoundingClientRect()
        this.mouseX = Math.round(event.clientX - rect.left)
        this.mouseY = Math.round(event.clientY - rect.top)
        
        // Throttle mouse move events in log
        if (!this._mouseMoveThrottle) {
            this._mouseMoveThrottle = true
            this.logEvent(`Mouse moved to (${this.mouseX}, ${this.mouseY})`, 'mouse')
            setTimeout(() => {
                this._mouseMoveThrottle = false
            }, 500)
        }
    },
    
    // Utility methods
    logEvent(eventDescription, type = 'general') {
        this.eventLog.unshift({
            timestamp: new Date().toLocaleTimeString(),
            event: eventDescription,
            type: type
        })
        
        // Keep only last 20 events
        if (this.eventLog.length > 20) {
            this.eventLog = this.eventLog.slice(0, 20)
        }
    },
    
    clearEventLog() {
        this.eventLog = []
        this.logEvent('Event log cleared', 'system')
    }
})
Live Preview
More Event Features: Event modifiers (data-event-prevent, data-event-debounce, keyboard filters, click-outside detection), custom events for component communication, and form event handling are covered on the Advanced Events page.

Event Handler Arguments

Event handlers receive three arguments:

Argument Type Description
event Event Native DOM event object
element HTMLElement Element that triggered the event
details Object Additional context (list item data, etc.)
<div data-component="arguments-demo">
    <div class="mb-4">
        <h5>Event Analysis</h5>
        <button data-action="analyzeEvent"
                class="btn btn-info me-2"
                data-custom="primary-button">
            Analyze This Click
        </button>
        <button data-action="analyzeEvent"
                class="btn btn-secondary"
                data-custom="secondary-button">
            Analyze This Click
        </button>
    </div>
    
    <div class="mb-4">
        <h5>List Items with Context (<span data-bind="itemCount"></span> items):</h5>
        <div class="mb-2">
            <button data-action="addRandomItem" class="btn btn-sm btn-success me-2">
                Add Random Item
            </button>
            <button data-action="resetItems" class="btn btn-sm btn-secondary">
                Reset Items
            </button>
        </div>
        <div data-list="items">
            <template>
                <div class="card mb-2">
                    <div class="card-body d-flex justify-content-between align-items-center">
                        <div>
                            <strong data-bind="name"></strong>
                            <small class="text-muted d-block">
                                Category: <span data-bind="category"></span> |
                                ID: <span data-bind="id"></span>
                            </small>
                        </div>
                        <div>
                            <button data-action="editItem"
                                    class="btn btn-sm btn-primary me-2"
                                    data-item-action="edit">
                                Edit
                            </button>
                            <button data-action="deleteItem"
                                    class="btn btn-sm btn-danger"
                                    data-item-action="delete">
                                Delete
                            </button>
                        </div>
                    </div>
                </div>
            </template>
        </div>
        <div data-show="isEmpty" class="text-center text-muted py-3">
            No items to display. Add some items to see context handling.
        </div>
    </div>
    
    <div class="mt-4">
        <h5>Last Event Details:</h5>
        <div style="background-color: var(--card-bg);">
            <pre data-bind="lastEventDetails" style="margin: 0; white-space: pre-wrap; font-size: 0.85em;"></pre>
        </div>
    </div>
</div>
wildflower.component('arguments-demo', {
    state: {
        items: [
            { id: 1, name: 'Task Alpha', category: 'work' },
            { id: 2, name: 'Task Beta', category: 'personal' },
            { id: 3, name: 'Task Gamma', category: 'work' }
        ],
        lastEventDetails: 'No events analyzed yet. Click a button or interact with list items to see event details.'
    },
    
    computed: {
        itemCount() {
            return this.items.length
        },
        
        isEmpty() {
            return this.items.length === 0
        }
    },
    
    analyzeEvent(event, element, details) {
        // Comprehensive event analysis
        const eventInfo = {
            // Event object properties
            event: {
                type: event.type,
                timestamp: new Date(event.timeStamp).toISOString(),
                bubbles: event.bubbles,
                cancelable: event.cancelable,
                target: {
                    tagName: event.target.tagName,
                    className: event.target.className,
                    textContent: event.target.textContent.substring(0, 50)
                }
            },
            
            // Element object properties
            element: {
                tagName: element.tagName,
                className: element.className,
                id: element.id || 'no-id',
                dataset: element.dataset,
                textContent: element.textContent.substring(0, 50)
            },
            
            // Details object (context from framework)
            details: details || 'No additional context provided',
            
            // Analysis metadata
            analysis: {
                eventAndElementSame: event.target === element,
                hasCustomData: Object.keys(element.dataset).length > 0,
                componentContext: this.constructor.name || 'unknown'
            }
        }
        
        this.lastEventDetails = JSON.stringify(eventInfo, null, 2)
        console.log('Event Analysis:', eventInfo)
    },
    
    editItem(event, element, details) {
        // Use details.index from the framework's action context
        const itemIndex = details.index
        const item = details.item

        const eventInfo = {
            action: 'Edit item',
            itemData: item,
            listContext: {
                itemIndex: itemIndex,
                totalItems: this.items.length,
                detailsProvided: true
            },
            elementInfo: {
                tag: element.tagName,
                classes: element.className.split(' '),
                customAttributes: element.dataset
            },
            eventDetails: {
                type: event.type,
                button: event.button || 'n/a',
                ctrlKey: event.ctrlKey,
                altKey: event.altKey
            }
        }

        this.lastEventDetails = JSON.stringify(eventInfo, null, 2)
    },

    deleteItem(event, element, details) {
        // Use details.index and details.item from the framework's action context
        const itemIndex = details.index
        const item = details.item

        if (confirm(`Delete "${item.name}"?`)) {
            this.items.splice(itemIndex, 1)

            const eventInfo = {
                action: 'Deleted item',
                deletedItem: item,
                listContext: {
                    itemWasAtIndex: itemIndex,
                    remainingItems: this.items.length,
                    listLength: this.items.length
                },
                eventContext: {
                    type: event.type,
                    elementClicked: element.textContent.trim()
                }
            }

            this.lastEventDetails = JSON.stringify(eventInfo, null, 2)
        }
    },

    addRandomItem() {
        const names = ['Task Delta', 'Task Epsilon', 'Task Zeta', 'Task Theta', 'Task Lambda']
        const categories = ['work', 'personal', 'urgent', 'research']

        const name = names[Math.floor(Math.random() * names.length)]
        const category = categories[Math.floor(Math.random() * categories.length)]
        const id = Date.now() + Math.floor(Math.random() * 1000)

        this.items.push({ id, name, category })

        this.lastEventDetails = `Added new item: ${JSON.stringify({ id, name, category }, null, 2)}`
    },

    resetItems() {
        this.items = [
            { id: 1, name: 'Task Alpha', category: 'work' },
            { id: 2, name: 'Task Beta', category: 'personal' },
            { id: 3, name: 'Task Gamma', category: 'work' }
        ]
        this.lastEventDetails = 'Items reset to original state.'
    }
})
Live Preview

Passing Arguments to Actions

You can pass literal arguments directly in data-action attributes. This eliminates the need for separate methods when the only difference is a parameter value.

Supported Literal Types

Type Examples Notes
String 'hello', "hello" Single or double quoted
Number 42, 3.14, -1, 0 Integer, decimal, negative
Boolean true, false Exact match
Null null Exact match

Syntax

Pattern Description Example
method('arg') Click handler with argument <button data-action="setPriority('high')">
method('a', 'b', 3) Multiple arguments <button data-action="configure('dark', 2, true)">
event:method('arg') Specific event with argument <input data-action="input:search('users')">

Accessing Arguments

Arguments are available in two ways: via details.args (an array), and as extra parameters appended after the standard (event, element, details) signature.

<div data-component="action-args-demo">
    <div class="mb-3">
        <h5>Priority: <span data-bind="priority"></span></h5>
        <button data-action="setPriority('high')" class="btn btn-sm btn-danger me-1">High</button>
        <button data-action="setPriority('medium')" class="btn btn-sm btn-warning me-1">Medium</button>
        <button data-action="setPriority('low')" class="btn btn-sm btn-success">Low</button>
    </div>

    <div class="mb-3">
        <h5>Opacity: <span data-bind="opacity"></span></h5>
        <button data-action="setOpacity(1)" class="btn btn-sm btn-secondary me-1">100%</button>
        <button data-action="setOpacity(0.5)" class="btn btn-sm btn-secondary me-1">50%</button>
        <button data-action="setOpacity(0)" class="btn btn-sm btn-secondary">0%</button>
    </div>

    <div>
        <h5>Last Action:</h5>
        <pre data-bind="lastAction"></pre>
    </div>
</div>
wildflower.component('action-args-demo', {
    state: {
        priority: 'medium',
        opacity: 1,
        lastAction: ''
    },

    setPriority(event, element, details) {
        // details.args = ['high'], ['medium'], or ['low']
        this.priority = details.args[0]
        this.lastAction = 'setPriority called with: ' + details.args[0]
    },

    setOpacity(event, element, details) {
        // details.args = [1], [0.5], or [0]
        this.opacity = details.args[0]
        this.lastAction = 'setOpacity called with: ' + details.args[0]
    }
})
Live Preview

In list contexts, details.args coexists with the standard list context properties (details.item, details.index, etc.):

<div data-list="tasks">
    <template>
        <div>
            <span data-bind="title"></span>
            <button data-action="setStatus('done')">Complete</button>
            <button data-action="setStatus('archived')">Archive</button>
        </div>
    </template>
</div>
setStatus(event, element, details) {
    const task = details.item    // list item for this row
    const status = details.args[0]  // 'done' or 'archived'
    task.status = status
}

Event Best Practices

✅ Do
  • Use descriptive handler method names
  • Prevent default behavior when needed
  • Validate form inputs on appropriate events
  • Clean up custom event listeners in destroy()
  • Use event delegation for dynamic content
❌ Don't
  • Modify state excessively in mouse move handlers
  • Use onclick="..." attributes; use data-action instead
  • Skip event.preventDefault() on form submissions
  • Add addEventListener in init() without removing in destroy()
  • Create separate methods when data-action="method('arg')" suffices