Skip to content

Commit

Permalink
adjusted envjs to satisfy all added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcher committed Feb 5, 2010
1 parent a33b57d commit 43f9217
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 38 deletions.
19 changes: 11 additions & 8 deletions dist/dom.js
Expand Up @@ -1109,7 +1109,7 @@ __extend__(Node.prototype, {
//there is no need to perform namespace checks since everything has already gone through them
//in order to have gotten into the DOM in the first place. The following line
//turns namespace checking off in ._isValidNamespace
__ownerDocument__(this)._performingImportNodeOperation = true;
__ownerDocument__(this).importing = true;

if (importedNode.nodeType == Node.ELEMENT_NODE) {
if (!__ownerDocument__(this).implementation.namespaceAware) {
Expand Down Expand Up @@ -1184,8 +1184,8 @@ __extend__(Node.prototype, {
}
}

//reset _performingImportNodeOperation
__ownerDocument__(this)._performingImportNodeOperation = false;
//reset importing
__ownerDocument__(this).importing = false;
return importNode;

},
Expand Down Expand Up @@ -2656,26 +2656,29 @@ Document = function(implementation, docParentWindow) {

this.nodeName = "#document";
// initially false, set to true by parser
this._parseComplete = false;
this.parsing = false;
this.baseURI = 'about:blank';

this.ownerDocument = null;

this._performingImportNodeOperation = false;
this.importing = false;

};
Document.prototype = new Node;
__extend__(Document.prototype,{
get localName(){
return null;
},
get textContent(){
return null;
},
get all(){
return this.getElementsByTagName("*");
},
get documentElement(){
var i, length = this.childNodes?this.childNodes.length:0;
for(i=0;i<length;i++){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
return this.childNodes[i];
}
}
Expand Down Expand Up @@ -2867,7 +2870,7 @@ __extend__(Document.prototype,{

var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribute) {

if (doc._performingImportNodeOperation == true) {
if (doc.importing == true) {
//we're doing an importNode operation (or a cloneNode) - in both cases, there
//is no need to perform any namespace checking since the nodes have to have been valid
//to have gotten into the DOM in the first place
Expand All @@ -2880,7 +2883,7 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut


//only check for namespaces if we're finished parsing
if (this._parseComplete == true) {
if (this.parsing == false) {

// if the qualifiedName is malformed
if (qName.localName.indexOf(":") > -1 ){
Expand Down
28 changes: 17 additions & 11 deletions dist/env.js
Expand Up @@ -1020,7 +1020,7 @@ __extend__(Node.prototype, {
}
},
get textContent(){
return this.nodeValue;
return this.nodeValue||"";
},
insertBefore : function(newChild, refChild) {
var prevNode;
Expand Down Expand Up @@ -1395,7 +1395,7 @@ __extend__(Node.prototype, {
//there is no need to perform namespace checks since everything has already gone through them
//in order to have gotten into the DOM in the first place. The following line
//turns namespace checking off in ._isValidNamespace
__ownerDocument__(this)._performingImportNodeOperation = true;
__ownerDocument__(this).importing = true;

if (importedNode.nodeType == Node.ELEMENT_NODE) {
if (!__ownerDocument__(this).implementation.namespaceAware) {
Expand Down Expand Up @@ -1470,8 +1470,8 @@ __extend__(Node.prototype, {
}
}

//reset _performingImportNodeOperation
__ownerDocument__(this)._performingImportNodeOperation = false;
//reset importing
__ownerDocument__(this).importing = false;
return importNode;

},
Expand Down Expand Up @@ -2319,6 +2319,9 @@ __extend__(DocumentFragment.prototype,{
},
toString : function(){
return "[object DocumentFragment]";
},
get localName(){
return null;
}
});

Expand Down Expand Up @@ -2368,10 +2371,10 @@ __extend__(ProcessingInstruction.prototype, {
return Node.PROCESSING_INSTRUCTION_NODE;
},
get xml(){
return "<?" + this.nodeName +" "+ this.nodeValue + " ?>";
return "<?" + this.nodeName +" "+ this.nodeValue + "?>";
},
toString : function(){
return "ProcessingInstruction #"+this._id;
return "[object ProcessingInstruction]";
}
});

Expand Down Expand Up @@ -2939,26 +2942,29 @@ Document = function(implementation, docParentWindow) {

this.nodeName = "#document";
// initially false, set to true by parser
this._parseComplete = false;
this.parsing = false;
this.baseURI = 'about:blank';

this.ownerDocument = null;

this._performingImportNodeOperation = false;
this.importing = false;

};
Document.prototype = new Node;
__extend__(Document.prototype,{
get localName(){
return null;
},
get textContent(){
return null;
},
get all(){
return this.getElementsByTagName("*");
},
get documentElement(){
var i, length = this.childNodes?this.childNodes.length:0;
for(i=0;i<length;i++){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
return this.childNodes[i];
}
}
Expand Down Expand Up @@ -3150,7 +3156,7 @@ __extend__(Document.prototype,{

var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribute) {

if (doc._performingImportNodeOperation == true) {
if (doc.importing == true) {
//we're doing an importNode operation (or a cloneNode) - in both cases, there
//is no need to perform any namespace checking since the nodes have to have been valid
//to have gotten into the DOM in the first place
Expand All @@ -3163,7 +3169,7 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut


//only check for namespaces if we're finished parsing
if (this._parseComplete == true) {
if (this.parsing == false) {

// if the qualifiedName is malformed
if (qName.localName.indexOf(":") > -1 ){
Expand Down
28 changes: 17 additions & 11 deletions dist/env.rhino.js
Expand Up @@ -1020,7 +1020,7 @@ __extend__(Node.prototype, {
}
},
get textContent(){
return this.nodeValue;
return this.nodeValue||"";
},
insertBefore : function(newChild, refChild) {
var prevNode;
Expand Down Expand Up @@ -1395,7 +1395,7 @@ __extend__(Node.prototype, {
//there is no need to perform namespace checks since everything has already gone through them
//in order to have gotten into the DOM in the first place. The following line
//turns namespace checking off in ._isValidNamespace
__ownerDocument__(this)._performingImportNodeOperation = true;
__ownerDocument__(this).importing = true;

if (importedNode.nodeType == Node.ELEMENT_NODE) {
if (!__ownerDocument__(this).implementation.namespaceAware) {
Expand Down Expand Up @@ -1470,8 +1470,8 @@ __extend__(Node.prototype, {
}
}

//reset _performingImportNodeOperation
__ownerDocument__(this)._performingImportNodeOperation = false;
//reset importing
__ownerDocument__(this).importing = false;
return importNode;

},
Expand Down Expand Up @@ -2319,6 +2319,9 @@ __extend__(DocumentFragment.prototype,{
},
toString : function(){
return "[object DocumentFragment]";
},
get localName(){
return null;
}
});

Expand Down Expand Up @@ -2368,10 +2371,10 @@ __extend__(ProcessingInstruction.prototype, {
return Node.PROCESSING_INSTRUCTION_NODE;
},
get xml(){
return "<?" + this.nodeName +" "+ this.nodeValue + " ?>";
return "<?" + this.nodeName +" "+ this.nodeValue + "?>";
},
toString : function(){
return "ProcessingInstruction #"+this._id;
return "[object ProcessingInstruction]";
}
});

Expand Down Expand Up @@ -2939,26 +2942,29 @@ Document = function(implementation, docParentWindow) {

this.nodeName = "#document";
// initially false, set to true by parser
this._parseComplete = false;
this.parsing = false;
this.baseURI = 'about:blank';

this.ownerDocument = null;

this._performingImportNodeOperation = false;
this.importing = false;

};
Document.prototype = new Node;
__extend__(Document.prototype,{
get localName(){
return null;
},
get textContent(){
return null;
},
get all(){
return this.getElementsByTagName("*");
},
get documentElement(){
var i, length = this.childNodes?this.childNodes.length:0;
for(i=0;i<length;i++){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
return this.childNodes[i];
}
}
Expand Down Expand Up @@ -3150,7 +3156,7 @@ __extend__(Document.prototype,{

var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribute) {

if (doc._performingImportNodeOperation == true) {
if (doc.importing == true) {
//we're doing an importNode operation (or a cloneNode) - in both cases, there
//is no need to perform any namespace checking since the nodes have to have been valid
//to have gotten into the DOM in the first place
Expand All @@ -3163,7 +3169,7 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut


//only check for namespaces if we're finished parsing
if (this._parseComplete == true) {
if (this.parsing == false) {

// if the qualifiedName is malformed
if (qName.localName.indexOf(":") > -1 ){
Expand Down
13 changes: 8 additions & 5 deletions src/dom/document.js
Expand Up @@ -29,26 +29,29 @@ Document = function(implementation, docParentWindow) {

this.nodeName = "#document";
// initially false, set to true by parser
this._parseComplete = false;
this.parsing = false;
this.baseURI = 'about:blank';

this.ownerDocument = null;

this._performingImportNodeOperation = false;
this.importing = false;

};
Document.prototype = new Node;
__extend__(Document.prototype,{
get localName(){
return null;
},
get textContent(){
return null;
},
get all(){
return this.getElementsByTagName("*");
},
get documentElement(){
var i, length = this.childNodes?this.childNodes.length:0;
for(i=0;i<length;i++){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
return this.childNodes[i];
}
}
Expand Down Expand Up @@ -240,7 +243,7 @@ __extend__(Document.prototype,{

var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribute) {

if (doc._performingImportNodeOperation == true) {
if (doc.importing == true) {
//we're doing an importNode operation (or a cloneNode) - in both cases, there
//is no need to perform any namespace checking since the nodes have to have been valid
//to have gotten into the DOM in the first place
Expand All @@ -253,7 +256,7 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut


//only check for namespaces if we're finished parsing
if (this._parseComplete == true) {
if (this.parsing == false) {

// if the qualifiedName is malformed
if (qName.localName.indexOf(":") > -1 ){
Expand Down
6 changes: 3 additions & 3 deletions src/dom/node.js
Expand Up @@ -463,7 +463,7 @@ __extend__(Node.prototype, {
//there is no need to perform namespace checks since everything has already gone through them
//in order to have gotten into the DOM in the first place. The following line
//turns namespace checking off in ._isValidNamespace
__ownerDocument__(this)._performingImportNodeOperation = true;
__ownerDocument__(this).importing = true;

if (importedNode.nodeType == Node.ELEMENT_NODE) {
if (!__ownerDocument__(this).implementation.namespaceAware) {
Expand Down Expand Up @@ -538,8 +538,8 @@ __extend__(Node.prototype, {
}
}

//reset _performingImportNodeOperation
__ownerDocument__(this)._performingImportNodeOperation = false;
//reset importing
__ownerDocument__(this).importing = false;
return importNode;

},
Expand Down

0 comments on commit 43f9217

Please sign in to comment.