Bug 774914 - Ensure newNode is orphan before replacing a node in JSDOMParser (r=mfinkle)
authorLucas Rocha <lucasr@mozilla.com>
Sat, 25 Aug 2012 11:27:27 +0100
changeset 103427 8182bfe539f8e94c93e9048db41309903bbcbb15
parent 103426 7e5db456160a178717f044d5fba40862c7402141
child 103428 5e2b2c9c4f670491189755b90f319da0d78e63f3
push id23348
push userryanvm@gmail.com
push dateSun, 26 Aug 2012 02:09:16 +0000
treeherdermozilla-central@b3cce81fef1a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs774914
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 774914 - Ensure newNode is orphan before replacing a node in JSDOMParser (r=mfinkle)
mobile/android/chrome/content/JSDOMParser.js
--- a/mobile/android/chrome/content/JSDOMParser.js
+++ b/mobile/android/chrome/content/JSDOMParser.js
@@ -318,16 +318,19 @@
     },
 
     replaceChild: function (newNode, oldNode) {
       let childNodes = this.childNodes;
       let childIndex = childNodes.indexOf(oldNode);
       if (childIndex == -1) {
         throw "replaceChild: node not found";
       } else {
+        if (newNode.parentNode)
+          newNode.parentNode.removeChild(newNode);
+
         childNodes[childIndex] = newNode;
         newNode.parentNode = this;
         oldNode.parentNode = null;
         return oldNode;
       }
     }
   };