diff --git a/lib/wed/wed.js b/lib/wed/wed.js
index <HASH>..<HASH> 100644
--- a/lib/wed/wed.js
+++ b/lib/wed/wed.js
@@ -86,6 +86,11 @@ Editor.prototype.init = function (widget, options) {
     // decorated with all kinds of HTML elements so we keep the two
     // separate.
     this.$data_root = this.$gui_root.clone();
+
+    // Put the data_root into a document fragment to keep rangy happy.
+    var frag = this.widget.ownerDocument.createDocumentFragment();
+    frag.appendChild(this.$data_root.get(0));
+
     domutil.linkTrees(this.$data_root.get(0), this.$gui_root.get(0));
     this.data_updater = new TreeUpdater(this.$data_root.get(0));
     this._gui_updater = new GUIUpdater(
Rangy won't work with data that is not in a document or a document fragment.