-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Trust svg #2097
Trust svg #2097
Conversation
I'll also add a SVG example in the docs |
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.
Neat work, fantastic turnaround!
I'd like to rely on the same API for HTML, tough we'd probably have to adapt the MathML can probably be done the same way, but I haven't tried. |
This lgtm, but I know little enough about the underlying pieces that I'm not gonna approve the review. @isiahmeadows is probably a better choice. |
@tivac I don't know much either. I knew there was a client-side markup parser, and I learnt how to use it yesterday. There may be corner cases that are not handled properly, similar to the As mentioned in Gitter, I've tried to abuse synchronous XHR with data:URI to parse SVG in IE9, but it is rejected (using |
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.
LGTM.
@@ -64,12 +71,16 @@ module.exports = function($window) { | |||
insertNode(parent, vnode.dom, nextSibling) | |||
return vnode.dom | |||
} | |||
function createHTML(parent, vnode, nextSibling) { | |||
var possibleParents = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"} |
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.
I appreciate pulling this out. (I almost did over half a dozen times, and just didn't.)
Actually, please don't merge this yet, it can be done without the DOMParser API after all:
I'll update this tomorrow evening. |
Here we go, less code, and IE9 compat (for the 1 out of 500 people who still use it worldwide 🙄 ) |
Add support for SVG in
m.trust()
strings, and someDOMParser
support in the mocks.Description
This leverages the
DOMParser
API (IE 10+) to enable users to usem.trust()
to create raw SVG fragments.How Has This Been Tested?
I've added corresponding tests for
render
and the mocks.The mocks test also pass in Firefox, Chrome, Safari IE11 and Edge (thanks to @Yatekii for the last two).
Types of changes
Checklist:
docs/change-log.md