-
Notifications
You must be signed in to change notification settings - Fork 219
Add support for raw HTML #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
src/Halogen/VDom/Driver.js
Outdated
var template = document.createElement('template'); | ||
html = html.trim(); // Never return a text node of whitespace as the result | ||
template.innerHTML = html; | ||
var newElement = template.content.firstChild; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean it only supports a single HTML element? That should at least be documented somewhere. Maybe with support for fragments it could be improved to capture all children.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't considered that .. but good point. I guess it does mean that.
It doesn't necessarily need to be like this but inserting multiple elements would need to happen at the parent of the current element. Which i think would make the code unnecessary more complicated and might not even be possible (what to do if the raw-html was the top halogen element).
Also i think it's unwanted to enter multiple nodes in one location. Because you can just put a node around it. i.e. <b>node1</b><b>node2</b>
into <div><b>node1</b><b>node2</b></div>
. Also another option the user can do [ H.rawHTML "<b>node1</b>", H.rawHTML "<b>node2</b>" ]
if the wrapper node is really unwanted
What could be done is count the amount of children and if it's more than 1 to show a console warning on runtime.
Yes and documentation.
* Console error on passing not exactly 1 element to rawHTML function
How can i compare the html string How can i make this more efficient ? Like comparing the new html string with the old one and not render in case they are the same ? |
tests pass
most examples are working. The ones that don't i don't think it's because of this PR but didn't look into it
comes with example of usage
Addresses #324
HalogenWidget
imo because the name doesn't cover the extra constructor. This would be a breaking change, while currently what is added i don't think it breaks anything so it could be updated in minor version of halogen library.rawHTML
just tohtml
orraw
?Review appreciated.