choojs / hyperx

🏷 - tagged template string virtual dom builder
BSD 2-Clause "Simplified" License
1.01k stars 48 forks source link

Self-closing tag error #77

Closed downeyfe closed 5 years ago

downeyfe commented 5 years ago

As of a few hours ago I've been getting an error (TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.) when using self-closing tags. I think it had something to do with the last release (2.5.3).

Full trace:

TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
    at Object.convert (/src/node_modules/jsdom/lib/jsdom/living/generated/Node.js:749:11)
    at DocumentFragment.appendChild (/src/node_modules/jsdom/lib/jsdom/living/generated/Node.js:280:29)
    at Object.createFragment (/src/node_modules/nanohtml/lib/browser.js:96:14)
    at /src/node_modules/hyperx/index.js:152:44
    at html (/src/myfile.js)

Sample code (using Nanohtml):

const element= html`
        <div />
    `;
yoshuawuyts commented 5 years ago

cc/ @goto-bus-stop I suspect this might have been the change landed in https://github.com/choojs/hyperx/pull/74

goto-bus-stop commented 5 years ago

yikes seems likely. will have a look!

(you can do npm install hyperx@2.5.2 to use the previous version in the mean time.)

goto-bus-stop commented 5 years ago

previously this actually generated a DOM like

<div>
    </div>

with a bunch of whitespace inside the tag, which also seems wrong. for now i'll revert 2.5.3 though, this needs a different approach

downeyfe commented 5 years ago

Fixed by reverting in 2.5.4. Closing for now, thanks.