From c72a63849b249319eb27f103f3c8e761070be8f9 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Fri, 5 Jul 2013 10:47:08 +0100 Subject: [PATCH] Add some more methods to the fake DOM These methods are needed to get static saving working in the browser again (click "Save Static" in the Demo tiddler) --- core/modules/utils/fakedom.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/modules/utils/fakedom.js b/core/modules/utils/fakedom.js index d4e96d1ce..ffef36ec5 100644 --- a/core/modules/utils/fakedom.js +++ b/core/modules/utils/fakedom.js @@ -39,6 +39,23 @@ TW_Element.prototype.appendChild = function(node) { node.parentNode = this; }; +TW_Element.prototype.removeChild = function(node) { + var p = this.children.indexOf(node); + if(p !== -1) { + this.children.splice(p,1); + } +}; + +TW_Element.prototype.hasChildNodes = function() { + return !!this.children.length; +}; + +Object.defineProperty(TW_Element.prototype, "firstChild", { + get: function() { + return this.children[0]; + } +}); + TW_Element.prototype.addEventListener = function(type,listener,useCapture) { // Do nothing };