-
Notifications
You must be signed in to change notification settings - Fork 267
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
Document fragments being removed from template element in html. #742
Comments
H, I've never worked with that. My expectation would also be that the content stays the same. It definitely needs some investigation. |
Ok, so I can confirm the issue is from Line 89 in a7f0f47
Slapping a dbg! before and after does show that the template contents are removed. See the debug statements below:
I took a look at I am not even sure this behaviour is intended from the From what I can tell the only way this could practically be solveable is through using html5ever directly, instead of calling their wrappers from Looking into TLDR;We will probably have to directly use I will attempt to solve it using the solutions above when I have some time. During my research I also found some other problems that could cause issues in the future, I will create an issue for them once I do more research 👍 . |
Maybe it's worth checking out |
It might be caused by this: servo/html5ever#464 |
Ok, I was able to fix this in nipper. Now I guess the only thing left doing is getting a PR merged with that change. |
In some cases the <template> tags should not be replaced, but kept as they are. This allows Closes: trunk-rs/trunk#742
I created a PR (importcjj/nipper#30) … let's see how that goes. |
I hope Im wrong but I heavily doubt it will be accepted. I instead made a fork replacing, nipper with lol_html. Should I create a PR, or will we wait for importcjj/nipper#30? |
Well if you have a PR which would completely replace nipper would definitely want to check it out. I have the feeling that a lol_html replacement might make things much more complicated, as the model seem quite different. Then again, I also think that Then again, it mostly works an didn't cause issues so far. So if we can get away with a small fix, that wouldn't be bad. Still |
Fixed by: #743 |
I just checked it locally and wanted to follow up on this. It looks like the output generated (at least for me) isn't what it should be.
|
I think the reason for this would be: fn append_html(&mut self, selector: &str, html: &str) -> Result<()> {
self.select_mut(selector, |el| {
el.after(html, lol_html::html_content::ContentType::Html);
Ok(())
})
} It's selecting the element and then inserting "after" it. So appending html to |
Should be fixed by 357f3c0 |
Yes you are correct. Apologies for missing that.
I can confirm it is fixed on my end as well. |
I'd leave this one open for a bit longer. Should we encounter something. It's a pretty deep change. Then again, it seems to just work. I am still unsure if this should simply go into |
I think a new release that includes I already found a two weird problems. Both when testing on the
After peppering debug statements around, I found a bit of info on what is happening. For some reason if the 4th ID is read before the 5th, the minification locks up, and the 5th ID is never found (so non of the attributes are replaced in debug mode). I am not exactly sure why this is happening. It is very late for me, I will look into them in more detail tomorrow and go over the changes that were made. |
For some reason the Since the whole thing felt random, I thought it could be related to the ordering of the pipelines execution (at the very least something about async). So I swapped out The solution mentioned above solves both of the previous problems, but leaves a bigger question of "Why is it happening?". For that I honestly don't have an idea. |
I can create a PR with the fix. However it does feel kind of janky since we dont know why it happened, and why it is solved. I can also try to collect more information on why it happens but I can't promise I will find anything. |
I found the problem and made a PR to fix it (it was related to the order the elements were modified, and the self-closing tag causing issues). Perhaps its a good idea to make a separate issue to document the differences between For example: This means people using self-closing tags with script elements, will have to replace them with the spec compliant version. This would be turning |
Thanks for taking a look at this. So yes, maybe it makes sense starting a new 0.20.x release cycle with a few alpha/beta/rc versions for this. |
Just to be clear, I think having a "breaking change" of requiring a spec compliant HTML page is fine. But we should put it into a breaking change release (0.20.x) and add a nice little warning. |
I think that's closed, but not released yet. |
I apologize as I wasn't able to take a look into this. Though one thing I wanted to ask is would you prefer an error or just a warning? Detecting the error is quite simple (a single conditional), but in case we want to provide extra information things would get quite messy. I think giving a warning would make things much simpler, as the user can just check the output to see where the truncation occurs to find the script tag that is causing the issue. |
Personally I would prefer an error, as it might break things. And I am sure people will ignore warnings. However, I could also understand that having an |
I was working on a website using client side templating with handlebars. I noticed that none of my templates were working.
Turns out building the HTML with trunk caused the document fragments in template elements to disappear.
Building with/without minification, using release/debug mode did not change anything, and using verbose flag on the cli didn't give any useful information.
I have tried tracking down why this happens. From my understanding it comes from parse_document from
html5ever
from thenipper
dependency (Its used when creating aDocument
).I am relatively new to these kind of stuff so take that information with a grain of salt, and since I am not really trusting in my findings I thought it would be better to create an issue here first in case I am overlooking something on the Trunk side.
Input:
Output:
Expected result:
The text was updated successfully, but these errors were encountered: