Content-Length: 305969 | pFad | http://github.com/purescript-halogen/purescript-halogen/pull/787

0D Add support for raw HTML by flip111 · Pull Request #787 · purescript-halogen/purescript-halogen · GitHub
Skip to content

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

flip111
Copy link

@flip111 flip111 commented Feb 8, 2022

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

  • Not sure for the best way to implement patch
  • ComponentSlot should be renamed to 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.
  • add documentation, only first element in raw html string will be used
  • rename function rawHTML just to html or raw?

Review appreciated.

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;
Copy link
Contributor

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.

Copy link
Author

@flip111 flip111 Feb 12, 2022

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.

@garyb garyb mentioned this pull request May 8, 2022
flip111 added 2 commits June 10, 2022 00:07
* Console error on passing not exactly 1 element to rawHTML function
@flip111
Copy link
Author

flip111 commented Jun 9, 2022

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 ?

@flip111 flip111 marked this pull request as draft April 16, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/purescript-halogen/purescript-halogen/pull/787

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy