@benev/nubs
Version:
user-input system for web games
15 lines (10 loc) • 299 B
text/typescript
import {NubContext} from "../../context/element.js"
export function stateForClosestContext(element: HTMLElement) {
return () => {
const context = element
.closest<NubContext>("nub-context")
if (!context)
throw new Error("parental nub-context element not found")
return context
}
}