hyperhype / hyperscript

Create HyperText with JavaScript.
MIT License
2.64k stars 110 forks source link

outerHTML throws TypeError: arr.forEach is not a function #95

Open virtualpatterns opened 3 years ago

virtualpatterns commented 3 years ago

I'm creating an Element using ...

let node = h('a', { 'attributes': { 'href': 'http:www.google.com' } }, 'Google')

... which is the style of hyperscript generated by html-to-hyperscript and html2hscript. When calling outerHTML on this Element ...

console.log(node.outerHTML)

... it throws ...

TypeError: arr.forEach is not a function
    at _stringify (/Volumes/DUMBLEDORE1/Users/fficnar/Projects/Shared Projects/mablung-pug/node_modules/html-element/index.js:291:9)
    at Element.outerHTML (/Volumes/DUMBLEDORE1/Users/fficnar/Projects/Shared Projects/mablung-pug/node_modules/html-element/index.js:336:48)
    at main (/Volumes/DUMBLEDORE1/Users/fficnar/Projects/Shared Projects/mablung-pug/source/sandbox/conv.js:24:22)
    at /Volumes/DUMBLEDORE1/Users/fficnar/Projects/Shared Projects/mablung-pug/source/sandbox/conv.js:32:1
    at ModuleJob.run (internal/modules/esm/module_job.js:140:23)
    at Loader.import (internal/modules/esm/loader.js:165:24)
    at Object.loadESM (internal/process/esm_loader.js:68:5)

Any ideas how to solve this? I suspect it's an html-element issue. If I change { 'attributes': { 'href': 'http:www.google.com' } }to { 'href': 'http:www.google.com' } it works ... but doesn't help since in my use the Element is automatically created from HTML.