WebReflection / hyperHTML

A Fast & Light Virtual DOM Alternative
ISC License
3.06k stars 112 forks source link

What is this html comment with a percent added to changed nodes? #352

Closed bschlenk closed 5 years ago

bschlenk commented 5 years ago

It looks like hyperhtml is adding weird comments to nodes that it changes, that look like <!---0.461211%-->. This is failing our nightwatch tests, which use innnerHTML to compare before and after dom content, which is including this bizarre comment. Is it hyperhtml that is adding this? Is it possible for me to disable this comment?

Scott-MacD commented 5 years ago

From my understanding those comments are vital to how hyperHTML works. I donโ€™t know the exact inner workings, but I believe it uses the exact nodes those comments create to be able to re-render content in a highly efficient manner.

WebReflection commented 5 years ago

Is it hyperhtml that is adding this?

Yes.

Is it possible for me to disable this comment?

No, that's how hyperHTML, or lit-html, or anything that needs to understand where your holes in your template literals were, reflects on the DOM.

This is failing our nightwatch tests, which use innnerHTML

Don't use innerHTML, it's been bad since day zero, why would you trust it for tests at all?

WebReflection commented 5 years ago

P.S. you can, however, just remove /<!--(?:-?\d\.\d+%)-->/g out of the equation, and you might be good to go with your innerHTML based tests ๐Ÿ‘‹