developit / undom

🍩 1kb minimally viable DOM Document implementation
https://npm.im/undom
MIT License
671 stars 25 forks source link

Support SVGElement #4

Closed tkh44 closed 8 years ago

tkh44 commented 8 years ago

Now that preact checks for instanceof SVGElement you are unable to test preact components using undom.

https://github.com/developit/preact/blob/fd4f21f5c45dfd75151bd27b4c217d8003aa5eb9/src/vdom/diff.js#L37

developit commented 8 years ago

Ahh - I had left this out because I wanted undom to treat SVG elements as regular elements, but I realize now this would throw because SVGElement would then be undefined. Perhaps undom can just export SVGElement as an alias of Element (thus making it global when pulled in via the polyfill).

tkh44 commented 8 years ago

I wasn't sure how to accomplish this either because of the straight call to SVGElement from window.

developit commented 8 years ago

The polyfill installs everything from document.defaultView as globals, so just adding the alias should make it a global as well.

developit commented 8 years ago

Let me know if you're able to test that this fixed things for you! :)

tkh44 commented 8 years ago

Ok will do

tkh44 commented 8 years ago

Tested and working!

I just did Object.assign(global, undom()). Is this the method you would use?

developit commented 8 years ago

That's basically all the polyfill does, just a little easier to type:

import 'undom/register';
// or
require('undom/register');
developit commented 8 years ago

I'll cut a release with this fix ASAP. Working on a V2 though ;)