Created
January 30, 2018 10:12
-
-
Save tonis2/1f7f87b34c4850b8b4bb0009c5f21d94 to your computer and use it in GitHub Desktop.
Convert string to HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.html = function() { | |
let parser = new DOMParser(); | |
let doc = parser.parseFromString(this, "text/html"); | |
return doc.body.firstChild; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment