{"size": 405, "ext": "js", "max_stars_repo_path": "src/toSafeHTMLDocument.js", "max_stars_repo_name": "ciurescugeorge6/prose-editor", "max_stars_repo_stars_event_min_datetime": "2018-11-06T17:21:18.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-17T01:07:57.000Z", "max_issues_repo_path": "src/toSafeHTMLDocument.js", "max_issues_repo_name": "drenther/czi-prosemirror", "max_issues_repo_issues_event_min_datetime": "2020-02-19T17:04:01.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-27T10:10:29.000Z", "max_forks_repo_path": "src/toSafeHTMLDocument.js", "max_forks_repo_name": "drenther/czi-prosemirror", "max_forks_repo_forks_event_min_datetime": "2018-11-25T21:41:00.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-02T09:20:19.000Z"}
{"max_stars_count": 301, "max_issues_count": 78, "max_forks_count": 63, "avg_line_length": 40.5, "max_line_length": 85, "alphanum_fraction": 0.775308642}
// @flow

// Parses HTML in a detached document to help with avoiding XSS
// https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Code_snippets/HTML_to_DOM
// https://github.com/ProseMirror/prosemirror/issues/473#issuecomment-255727531
export default function toSafeHTMLDocument(html: string): ?Document {
  const parser = new window.DOMParser();
  return parser.parseFromString(html, 'text/html');
}
