Closed bitinn closed 9 years ago
The main difference between vdom-virtualize
and html-to-vdom
, besides the parser, is that virtualize wrap text node with a vnode in output, as you can see in the first 2 tests:
https://github.com/bitinn/vdom-virtualize/blob/test-cases/test/index.js#L11
Not sure which is preferred, love to hear @TimBeyer 's opinion.
I should also note that I modified some of the tests to better reflect how browser dom work:
eg. if you set shorthand style background: red
, it will be expanded to background-color: red
and other background properties, this is a potential gotcha. (obviously js-based html parser like htmlparser2
won't do this because they are not fully CSS aware like browsers)
@bitinn In my opinion, the right approach is clearly creating only a TextNode
in case there is text only.
If the chain html -> vdom -> html
does not create the same output as it got input, I consider the implementation broken. That clearly would be the case for something like
Just Text
-> VNode(VText('Just Text'))
-> <div>Just Text</div>
.
mhpf, closing this wasn't my intention of course...
please see my updated PR #29
Hi @marcelklehr, I migrated test cases from https://github.com/TimBeyer/html-to-vdom to this repo. Could you take a look?
This is also partly due to a discussion we are having about using
virtual-dom
for progressive enhancement (at least I would like to get them working). ref: https://github.com/Matt-Esch/virtual-dom/issues/227#issuecomment-99420341Changes I have made:
html-to-vdom
, do note my comments in the test file, innerHTML behaves differently fromhtmlparser2
, so there are difference betweenvdom-virtualize
andhtml-to-vdom
.npm run dist
command to buildbundle.js
.gitignore
fileYou should be able to run
npm test
after anpm install
, it will open a localhost to run test cases in your default browser. I tried to get Testling CI (cross-browser tests) working but they API appear to be broken since 2015, so that needs more work.