-
Notifications
You must be signed in to change notification settings - Fork 171
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
Parse html using $.parseHTML. #361
Conversation
@@ -927,6 +925,12 @@ LayoutManager.prototype.options = { | |||
// Override this with a custom HTML method, passed a root element and content | |||
// (a jQuery collection or a string) to replace the innerHTML with. | |||
html: function($root, content) { | |||
// Use $.parseHTML to safely convert strings into HTML. Cheerio requires |
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.
Is that really necessary? Can a string end up here without that being a bug?
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.
Yeah, strings would reach it through applyTemplate, if manager.noel
was false. I fixed that in the next commit and removed $.parseHTML
from options.html
.
I like the simplified version! Although, I think the |
@ssafejava I wrote the same code yesterday after Cheerio 0.12.1 was published, but I felt that it's only exchanging one sub-optimal shim for another. @SBoudrias is correct--this is a bug in Cheerio. We might as well stick with what works for now until we have a complete solution. As I mentioned earlier, I'm taking responsibility for #351. It's just going to take a little more time:
|
Thanks for handling it @jugglinmike! I can leave the PR open and we can just patch it to remove the
|
@ssafejava yup, that's what we're gonna do. We got the jQuery API docs updated (live now) and are progressing with the next step in keeping the Cheerio API matching closer. |
on the correct el after rerendering with el:false.
…rseHTML` from `options.html`.
I removed the wrapper and updated the test's intention to not be focused on trimming, but instead the retaining source via parseHTML. We're going to merge this as soon as Cheerio releases a version bump with @jugglinmike's fixes. |
Closed in #380 |
See #351. In version 0.12.1, cheerio supports
$.parseHTML
. More on$.parseHTML
from jQuery's tracker.@jugglinmike, what do you think about wrapping the return value of
$.parseHTML
in cheerio inside$()
? While all tests pass in the browser with an unwrapped$.parseHTML
call, they fail in cheerio - I get the following output using console.log in the tests: