I’d like to assign part of the DOM tree to global variable, so that there isn’t reference with my variable and DOM tree any more. The part of the DOM tree should be copied to global variable and when I make changes to DOM tree it shouldn’t change my variable.
Normal assignment does not do it.
clarification with code snippet:
var children;
var Test {
x: function(e) {
...
children = e.target.ownerDocument.getElementsByTagName('body')[0].childNodes; // rowX
...
e.target.ownerDocument.getElementsByTagName('body')[0].innerHTML = somethingElse; // rowY
}
}
The problem is that I want have something stored in children variable (rowX) and rowY will change children variable as a side effect, so there is some reference with the DOM tree yet.
thank you for tip
In this case you may want to use the
cloneNode(deep:Boolean)method: