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

should createContextualFragment be added in Document / DocumentFragment? #33

Closed
caub opened this issue Nov 13, 2017 · 4 comments
Closed

Comments

@caub
Copy link

caub commented Nov 13, 2017

instead of in Range prototype, I think it could be great to just do document.createContextualRange('<br>')

@annevk
Copy link
Member

annevk commented Nov 13, 2017

It would help if you started with a problem statement, before going to what the solution might look like. See also https://whatwg.org/faq#adding-new-features.

@caub
Copy link
Author

caub commented Nov 13, 2017

Hi, right, sorry

Basically I often need this feature 'isomorphically' (browser + node) (example: writing a module parsing html, filterXSS, etc..), jsdom has a convenient JSDOM.fragment(str) static helper.

I wonder a bit why it was added in Range.prototype, it doesn't even return a Range. So the current way to access createContextualFragment in DOM is not practical, maybe you would agree

@annevk
Copy link
Member

annevk commented Nov 13, 2017

It's a legacy API that all browsers were forced to adopt. I don't recall reading about the design history.

@caub
Copy link
Author

caub commented Nov 23, 2017

I think there's some work concerning <template> that could make html parsing easier. Thanks, I knew Range and editing APIs are more than 15 years old, but I was wondering if this particular method could be extracted in a more accessible class/object

let's close it, maybe and thanks again

@caub caub closed this as completed Nov 23, 2017
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

No branches or pull requests

2 participants