Skip to content
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

Implement static method Element.of(html) #1521

Closed
wants to merge 3 commits into from

Conversation

suarez12138
Copy link
Contributor

@suarez12138 suarez12138 commented Apr 24, 2021

I implement Element.of(html) mentioned in #1411 by using method element.html(), while using a <div> to be the top element can succeed in most situation, but can not hold cases like input tag <html>. I will glad to work more on this and welcome your code reviews.

@jhy
Copy link
Owner

jhy commented Dec 19, 2021

Thanks, it's interesting. Sorry for the late reply! The main thing that I think is missing is that it's a static method and doesn't allow any of the configured HTML parser settings to flow (e.g case sensitivity, or XML vs HTML parsing, etc). So it could only be useful in the context of the default parser, which is frequently not what people actually want.

My suggestion would be to do something like making it a method of Document. Like Element el = document.elementOf("<p>")....

And grab the parser from Document and use the parse fragment methods.

Also I think most of the validation, and particularly the string validation, should be removed. It seems both an artificial constraint, and doing string checks vs validating the parser output seems risky / unneccesary.

@jhy jhy mentioned this pull request Dec 19, 2021
@jhy
Copy link
Owner

jhy commented Jun 24, 2022

Will close for now per my previous notes.

@jhy jhy closed this Jun 24, 2022
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