JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
code cleanup (no IE8 support)
[peach-html5-editor.git] / editor.js
index 66b835b..72e8506 100644 (file)
--- a/editor.js
+++ b/editor.js
@@ -429,7 +429,7 @@ 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
@@ -450,13 +450,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 +1672,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('<p style="white-space: pre-wrap"> </p>', this.parser_opts)
+               this.tree = peach_parser.parse('<p style="white-space: pre-wrap"> </p>', this.parser_opts)
        }
        this.tree_parent = this.tree[0].parent
        this.tree_parent.el = this.idoc.body