X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=editor.js;h=9a3a2f5b59a36448a69a01ec54ab3354a2f5f3c5;hb=b9846ac6af1bcfa12e7a586df54789a571aa9ecc;hp=66b835b589015155f1323b15ca4c784124913cfa;hpb=2fa7d2835a89e76d51e33f0c8c79dbf9d5b818f8;p=peach-html5-editor.git diff --git a/editor.js b/editor.js index 66b835b..9a3a2f5 100644 --- a/editor.js +++ b/editor.js @@ -429,11 +429,16 @@ function instantiate_tree (tree, parent) { case 'tag': if (c.name === 'script' || c.name === 'object' || c.name === 'iframe' || c.name === 'link') { // TODO put placeholders instead - remove.unshift(i) + remove.unshift(i) // add to beginning so they are removed last first continue } - // TODO create in correct namespace - c.el = parent.ownerDocument.createElement(c.name) + if (c.namespace === 'svg') { + c.el = parent.ownerDocument.createElementNS('http://www.w3.org/2000/svg', c.name) + } else if (c.namespace === 'mathml') { + c.el = parent.ownerDocument.createElementNS('http://www.w3.org/1998/Math/MathML', c.name) + } else { + c.el = parent.ownerDocument.createElement(c.name) + } ref1 = c.attrs for (k in ref1) { v = ref1[k] @@ -450,13 +455,11 @@ function instantiate_tree (tree, parent) { } } } - results = [] + // these are in reverse order so we remove highest indexes first for (i = 0; i < remove.length; i++) { - // FIXME this deletes the wrong node when siblings are removed index = remove[i] - results.push(tree.splice(index, 1)) + tree.splice(index, 1) } - return results } function traverse_tree (tree, cb) { @@ -1674,9 +1677,9 @@ PeachHTML5Editor.prototype.clear_dom = function() { this.kill_cursor() } PeachHTML5Editor.prototype.load_html = function(html) { - this.tree = peach_parser(html, this.parser_opts) + this.tree = peach_parser.parse(html, this.parser_opts) if (this.tree[0] == null ? true : this.tree[0].parent == null) { - this.tree = peach_parser('

', this.parser_opts) + this.tree = peach_parser.parse('

', this.parser_opts) } this.tree_parent = this.tree[0].parent this.tree_parent.el = this.idoc.body