Skip to content
This repository has been archived by the owner on Mar 1, 2019. It is now read-only.

Commit

Permalink
Correcting parsing for svg elements in unescaped html (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
MattDeeg authored and andrewrota committed Feb 9, 2017
1 parent 5f024c9 commit cce8283
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/template/html_parser.js
Expand Up @@ -35,6 +35,10 @@ var defaultStack = new DefaultStack(true);
var _stack;
var parser = new TungstenParser({
onopentag: function(name, attributes) {
if (name === 'svg' || this.inSvg) {
attributes.namespace = 'http://www.w3.org/2000/svg';
this.inSvg = true;
}
_stack.openElement(name, attributes);
},
oncomment: function(text) {
Expand All @@ -43,7 +47,10 @@ var parser = new TungstenParser({
ontext: function(text) {
_stack.createObject(text);
},
onclosetag: function() {
onclosetag: function(name) {
if (name === 'svg') {
this.inSvg = false;
}
var el = _stack.peek();
_stack.closeElement(el);
}
Expand Down

0 comments on commit cce8283

Please sign in to comment.