Skip to content

Commit

Permalink
added tests for DocumentFragment.cloneNode
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcher committed Feb 8, 2010
1 parent cd34da2 commit 0e1bc1c
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 159 deletions.
53 changes: 26 additions & 27 deletions dist/dom.js
Expand Up @@ -734,7 +734,14 @@ __extend__(Node.prototype, {
}
},
get textContent(){
return this.nodeValue||"";
return __recursivelyGatherText__(this);
},
set textContent(newText){
while(this.firstChild != null){
this.removeChild( this.firstChild );
}
var text = this.ownerDocument.createTextNode(newText);
this.appendChild(text);
},
insertBefore : function(newChild, refChild) {
var prevNode;
Expand Down Expand Up @@ -1289,9 +1296,20 @@ var __ownerDocument__ = function(node){
return (node.nodeType == Node.DOCUMENT_NODE)?node:node.ownerDocument;
};

/**
* @author envjs team
*/

var __recursivelyGatherText__ = function(aNode) {
var accumulateText = "",
idx,
node;
for (idx=0;idx < aNode.childNodes.length;idx++){
node = aNode.childNodes.item(idx);
if(node.nodeType == Node.TEXT_NODE)
accumulateText += node.data;
else
accumulateText += __recursivelyGatherText__(node);
}
return accumulateText;
};

/**
* function __escapeXML__
Expand Down Expand Up @@ -1753,16 +1771,6 @@ __extend__(Element.prototype, {
return this.nodeName;
},

get textContent(){
return __recursivelyGatherText__(this);
},
set textContent(newText){
while(this.firstChild != null){
this.removeChild( this.firstChild );
}
var text = this.ownerDocument.createTextNode(newText);
this.appendChild(text);
},
getAttribute: function(name) {
var ret = null;
// if attribute exists, use it
Expand Down Expand Up @@ -1960,18 +1968,6 @@ __extend__(Element.prototype, {
}
});

var __recursivelyGatherText__ = function(aNode) {
var accumulateText = "";
var idx; var n;
for (idx=0;idx < aNode.childNodes.length;idx++){
n = aNode.childNodes.item(idx);
if(n.nodeType == Node.TEXT_NODE)
accumulateText += n.data;
else
accumulateText += __recursivelyGatherText__(n);
}
return accumulateText;
};

/**
* @class DOMException - raised when an operation is impossible to perform
Expand Down Expand Up @@ -2039,7 +2035,7 @@ __extend__(DocumentFragment.prototype,{
}
});


/**
* @class ProcessingInstruction -
* The ProcessingInstruction interface represents a
Expand All @@ -2066,6 +2062,9 @@ __extend__(ProcessingInstruction.prototype, {
}
this.nodeValue = data;
},
get textContent(){
return this.data;
},
get localName(){
return null;
},
Expand Down
69 changes: 30 additions & 39 deletions dist/env.js
Expand Up @@ -1035,7 +1035,14 @@ __extend__(Node.prototype, {
}
},
get textContent(){
return this.nodeValue||"";
return __recursivelyGatherText__(this);
},
set textContent(newText){
while(this.firstChild != null){
this.removeChild( this.firstChild );
}
var text = this.ownerDocument.createTextNode(newText);
this.appendChild(text);
},
insertBefore : function(newChild, refChild) {
var prevNode;
Expand Down Expand Up @@ -1590,9 +1597,20 @@ var __ownerDocument__ = function(node){
return (node.nodeType == Node.DOCUMENT_NODE)?node:node.ownerDocument;
};

/**
* @author envjs team
*/

var __recursivelyGatherText__ = function(aNode) {
var accumulateText = "",
idx,
node;
for (idx=0;idx < aNode.childNodes.length;idx++){
node = aNode.childNodes.item(idx);
if(node.nodeType == Node.TEXT_NODE)
accumulateText += node.data;
else
accumulateText += __recursivelyGatherText__(node);
}
return accumulateText;
};

/**
* function __escapeXML__
Expand Down Expand Up @@ -2054,16 +2072,6 @@ __extend__(Element.prototype, {
return this.nodeName;
},

get textContent(){
return __recursivelyGatherText__(this);
},
set textContent(newText){
while(this.firstChild != null){
this.removeChild( this.firstChild );
}
var text = this.ownerDocument.createTextNode(newText);
this.appendChild(text);
},
getAttribute: function(name) {
var ret = null;
// if attribute exists, use it
Expand Down Expand Up @@ -2261,18 +2269,6 @@ __extend__(Element.prototype, {
}
});

var __recursivelyGatherText__ = function(aNode) {
var accumulateText = "";
var idx; var n;
for (idx=0;idx < aNode.childNodes.length;idx++){
n = aNode.childNodes.item(idx);
if(n.nodeType == Node.TEXT_NODE)
accumulateText += n.data;
else
accumulateText += __recursivelyGatherText__(n);
}
return accumulateText;
};

/**
* @class DOMException - raised when an operation is impossible to perform
Expand Down Expand Up @@ -2340,7 +2336,7 @@ __extend__(DocumentFragment.prototype,{
}
});


/**
* @class ProcessingInstruction -
* The ProcessingInstruction interface represents a
Expand All @@ -2367,6 +2363,9 @@ __extend__(ProcessingInstruction.prototype, {
}
this.nodeValue = data;
},
get textContent(){
return this.data;
},
get localName(){
return null;
},
Expand Down Expand Up @@ -4365,17 +4364,9 @@ __extend__(HTMLDocument.prototype, {
if(!uri){
return this.createElement(local);
}else if ("http://www.w3.org/1999/xhtml" == uri) {
return this.createElement(local);
return this.createElement(local);
} else if ("http://www.w3.org/1998/Math/MathML" == uri) {
if (!this.mathplayerinitialized) {
var obj = this.createElement("object");
obj.setAttribute("id", "mathplayer");
obj.setAttribute("classid", "clsid:32F66A20-7614-11D4-BD11-00104BD3F987");
this.getElementsByTagName("head")[0].appendChild(obj);
this.namespaces.add("m", "http://www.w3.org/1998/Math/MathML", "#mathplayer");
this.mathplayerinitialized = true;
}
return this.createElement("m:" + local);
return this.createElement(local);
} else {
return Document.prototype.createElementNS.apply(this,[uri, local]);
}
Expand Down Expand Up @@ -5152,8 +5143,8 @@ var inputElements_focusEvents = {
__blur__(this);

if (this._oldValue != this.value){
var event = document.createEvent();
event.initEvent("change");
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
this.dispatchEvent( event );
}
},
Expand Down
69 changes: 30 additions & 39 deletions dist/env.rhino.js
Expand Up @@ -1035,7 +1035,14 @@ __extend__(Node.prototype, {
}
},
get textContent(){
return this.nodeValue||"";
return __recursivelyGatherText__(this);
},
set textContent(newText){
while(this.firstChild != null){
this.removeChild( this.firstChild );
}
var text = this.ownerDocument.createTextNode(newText);
this.appendChild(text);
},
insertBefore : function(newChild, refChild) {
var prevNode;
Expand Down Expand Up @@ -1590,9 +1597,20 @@ var __ownerDocument__ = function(node){
return (node.nodeType == Node.DOCUMENT_NODE)?node:node.ownerDocument;
};

/**
* @author envjs team
*/

var __recursivelyGatherText__ = function(aNode) {
var accumulateText = "",
idx,
node;
for (idx=0;idx < aNode.childNodes.length;idx++){
node = aNode.childNodes.item(idx);
if(node.nodeType == Node.TEXT_NODE)
accumulateText += node.data;
else
accumulateText += __recursivelyGatherText__(node);
}
return accumulateText;
};

/**
* function __escapeXML__
Expand Down Expand Up @@ -2054,16 +2072,6 @@ __extend__(Element.prototype, {
return this.nodeName;
},

get textContent(){
return __recursivelyGatherText__(this);
},
set textContent(newText){
while(this.firstChild != null){
this.removeChild( this.firstChild );
}
var text = this.ownerDocument.createTextNode(newText);
this.appendChild(text);
},
getAttribute: function(name) {
var ret = null;
// if attribute exists, use it
Expand Down Expand Up @@ -2261,18 +2269,6 @@ __extend__(Element.prototype, {
}
});

var __recursivelyGatherText__ = function(aNode) {
var accumulateText = "";
var idx; var n;
for (idx=0;idx < aNode.childNodes.length;idx++){
n = aNode.childNodes.item(idx);
if(n.nodeType == Node.TEXT_NODE)
accumulateText += n.data;
else
accumulateText += __recursivelyGatherText__(n);
}
return accumulateText;
};

/**
* @class DOMException - raised when an operation is impossible to perform
Expand Down Expand Up @@ -2340,7 +2336,7 @@ __extend__(DocumentFragment.prototype,{
}
});


/**
* @class ProcessingInstruction -
* The ProcessingInstruction interface represents a
Expand All @@ -2367,6 +2363,9 @@ __extend__(ProcessingInstruction.prototype, {
}
this.nodeValue = data;
},
get textContent(){
return this.data;
},
get localName(){
return null;
},
Expand Down Expand Up @@ -4365,17 +4364,9 @@ __extend__(HTMLDocument.prototype, {
if(!uri){
return this.createElement(local);
}else if ("http://www.w3.org/1999/xhtml" == uri) {
return this.createElement(local);
return this.createElement(local);
} else if ("http://www.w3.org/1998/Math/MathML" == uri) {
if (!this.mathplayerinitialized) {
var obj = this.createElement("object");
obj.setAttribute("id", "mathplayer");
obj.setAttribute("classid", "clsid:32F66A20-7614-11D4-BD11-00104BD3F987");
this.getElementsByTagName("head")[0].appendChild(obj);
this.namespaces.add("m", "http://www.w3.org/1998/Math/MathML", "#mathplayer");
this.mathplayerinitialized = true;
}
return this.createElement("m:" + local);
return this.createElement(local);
} else {
return Document.prototype.createElementNS.apply(this,[uri, local]);
}
Expand Down Expand Up @@ -5152,8 +5143,8 @@ var inputElements_focusEvents = {
__blur__(this);

if (this._oldValue != this.value){
var event = document.createEvent();
event.initEvent("change");
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
this.dispatchEvent( event );
}
},
Expand Down
16 changes: 4 additions & 12 deletions dist/html.js
Expand Up @@ -239,17 +239,9 @@ __extend__(HTMLDocument.prototype, {
if(!uri){
return this.createElement(local);
}else if ("http://www.w3.org/1999/xhtml" == uri) {
return this.createElement(local);
return this.createElement(local);
} else if ("http://www.w3.org/1998/Math/MathML" == uri) {
if (!this.mathplayerinitialized) {
var obj = this.createElement("object");
obj.setAttribute("id", "mathplayer");
obj.setAttribute("classid", "clsid:32F66A20-7614-11D4-BD11-00104BD3F987");
this.getElementsByTagName("head")[0].appendChild(obj);
this.namespaces.add("m", "http://www.w3.org/1998/Math/MathML", "#mathplayer");
this.mathplayerinitialized = true;
}
return this.createElement("m:" + local);
return this.createElement(local);
} else {
return Document.prototype.createElementNS.apply(this,[uri, local]);
}
Expand Down Expand Up @@ -1026,8 +1018,8 @@ var inputElements_focusEvents = {
__blur__(this);

if (this._oldValue != this.value){
var event = document.createEvent();
event.initEvent("change");
var event = document.createEvent("HTMLEvents");
event.initEvent("change", true, true);
this.dispatchEvent( event );
}
},
Expand Down
3 changes: 2 additions & 1 deletion dist/window.js
Expand Up @@ -273,7 +273,7 @@ Screen = function(__window__){
* @param {Object} opener
*/
Window = function(scope, parent, opener){

// console.log('new window %s', scope);
// the window property is identical to the self property and to this obj
var proxy = new Envjs.proxy(scope, parent);
scope.__proxy__ = proxy;
Expand Down Expand Up @@ -429,6 +429,7 @@ Window = function(scope, parent, opener){
return $location;
},
set location(uri){
new Window(this, this.parent, this.opener);
if($location.href == uri){
$location.reload();
}else if($location.href == 'about:blank'){
Expand Down

0 comments on commit 0e1bc1c

Please sign in to comment.