# hyperscript-nested-contexts **Repository Path**: mirrors_regular/hyperscript-nested-contexts ## Basic Information - **Project Name**: hyperscript-nested-contexts - **Description**: Create hyperscript contexts within hyperscript contexts and clean them up properly - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-25 - **Last Updated**: 2026-05-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # hyperscript-nested-contexts Hyperscript's `context()` function returns an object that implements the hyperscript API, but it misses a `context()` function itself. This module fixes this. ``` require('hyperscript').context().conext() ``` ## Example ``` const hs = require('hyperscript-nested-contexts')(require('hyperscript')) const ho = require('hyperobj') const observable = require('observable') const render = ho( function(v) { if (typeof v!=='object') return const h = this.ctx || hs return h('ol', Object.keys(v).map( (k)=> { const msg = observable() return (function(h) { msg('clickme') return h('li', [ h('em.key', h('span', msg), this.call(this, k), { onclick: function() { msg('I was clicked') h.cleanup() } }), h('span.value', this.call(this, v[k], k)) ]) }).call(this, this.ctx = h.context()) }) ) }, function(v) { const h = this.ctx || hs return h('span.string', v) } ) document.body.appendChild( render(require('./package.json')) ) ``` (Clicking on a parent will remove event handlers and observables from children)