dy / xhtm

XHTM − eXtended Hyperscript Tagged Markup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Runtime error on block-level element included in other block-level element. (TypeError: Cannot read properties of null (reading 'push'))

aral opened this issue · comments

import xhtm from 'xhtm'
import vhtml from 'vhtml' 

const html = xhtm.bind(vhtml)
const markup = html`<p><div onclick=${`&<>"'`}></div></p>`

console.log(markup)

Error:

file:///var/home/aral/sandbox/xhtm/node_modules/xhtm/htm.js:26
    current.push(h(last, ...args))
            ^

TypeError: Cannot read properties of null (reading 'push')
    at up (file:///var/home/aral/sandbox/xhtm/node_modules/xhtm/htm.js:26:13)
    at file:///var/home/aral/sandbox/xhtm/node_modules/xhtm/htm.js:81:9
    at String.replace (<anonymous>)
    at Function.htm (file:///var/home/aral/sandbox/xhtm/node_modules/xhtm/htm.js:37:9)
    at file:///var/home/aral/sandbox/xhtm/index.js:6:20
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)

Node.js v19.6.0

This is due to a block-level element being included in another block-level element, which is invalid HTML.

Not sure how xhtm should (or should not) handle these. I guess a nicer error message would be good but you also don’t want to make it into an html validator.

Added a nicer message Wrong close tag 'p'. Thanks!