Skip to content

Commit

Permalink
reapplied steven woods patches to tables and correction thanks to Bre…
Browse files Browse the repository at this point in the history
…tt Graf
  • Loading branch information
thatcher committed Nov 12, 2009
1 parent ee757ff commit 09e691c
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 42 deletions.
36 changes: 22 additions & 14 deletions dist/env.js
Expand Up @@ -1884,7 +1884,7 @@ __extend__(DOMElement.prototype, {
}*/

// assign values to properties (and aliases)
attr.value = value;
attr.value = value + '';

// add/replace Attribute in NamedNodeMap
this.attributes.setNamedItem(attr);
Expand Down Expand Up @@ -3750,7 +3750,7 @@ __extend__(DOMImplementation.prototype,{
* @return : DOMDocument
*/

function __parseLoop__(impl, doc, p, isWindowDocument) {
/*function __parseLoop__(impl, doc, p, isWindowDocument) {
var iEvt, iNode, iAttr, strName;
var iNodeParent = doc;

Expand Down Expand Up @@ -4027,12 +4027,12 @@ function __parseLoop__(impl, doc, p, isWindowDocument) {
else if(iEvt == XMLP._NONE) { // no more events
//steven woods notes that unclosed tags are rejected elsewhere and this check
//breaks a table patching routine
/*if (iNodeParent == doc) { // confirm that we have recursed back up to root
break;
}
else {
throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
}*/
//if (iNodeParent == doc) { // confirm that we have recursed back up to root
// break;
//}
//else {
// throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
//}
break;

}
Expand Down Expand Up @@ -4081,7 +4081,7 @@ function __parseLoop__(impl, doc, p, isWindowDocument) {
}

}
};
};*/


/**
Expand Down Expand Up @@ -7309,7 +7309,7 @@ __extend__(HTMLTableElement.prototype, {
}
},

/*appendChild : function (child) {
appendChild : function (child) {

var tagName;
if(child.tagName){
Expand All @@ -7334,7 +7334,7 @@ __extend__(HTMLTableElement.prototype, {
}else{
$error('HTMLTableElement.appendChild => child.tagName should not be undefined here... Fix ME!');
}
},*/
},

get tBodies() {
return new HTMLCollection(this.getElementsByTagName("tbody"));
Expand Down Expand Up @@ -7365,8 +7365,7 @@ __extend__(HTMLTableElement.prototype, {
// the row is appended as the last row. If index is omitted
// or greater than the number of rows, an error will result
if (idx === -1 || idx === numRows) {
lastRow = rows[rows.length-1];
lastRow.parentNode.appendChild(inserted);
this.appendChild(inserted);
} else {
rows[idx].parentNode.insertBefore(inserted, rows[idx]);
}
Expand Down Expand Up @@ -7613,6 +7612,13 @@ var HTMLTableRowElement = function(ownerDocument) {
HTMLTableRowElement.prototype = new HTMLElement;
__extend__(HTMLTableRowElement.prototype, {

appendChild : function (child) {

var retVal = DOMNode.prototype.appendChild.apply(this, arguments);
retVal.cellIndex = this.cells.length -1;

return retVal;
},
// align gets or sets the horizontal alignment of data within cells of the row.
get align() {
return this.getAttribute("align");
Expand Down Expand Up @@ -7693,9 +7699,11 @@ __extend__(HTMLTableRowElement.prototype, {
}

this.insertBefore(cell, node);

cell.cellIndex = idx;

return cell;
},


deleteCell : function (idx) {
var elem = this.cells[idx];
Expand Down
36 changes: 22 additions & 14 deletions dist/env.rhino.js
Expand Up @@ -2514,7 +2514,7 @@ __extend__(DOMElement.prototype, {
}*/

// assign values to properties (and aliases)
attr.value = value;
attr.value = value + '';

// add/replace Attribute in NamedNodeMap
this.attributes.setNamedItem(attr);
Expand Down Expand Up @@ -4380,7 +4380,7 @@ __extend__(DOMImplementation.prototype,{
* @return : DOMDocument
*/

function __parseLoop__(impl, doc, p, isWindowDocument) {
/*function __parseLoop__(impl, doc, p, isWindowDocument) {
var iEvt, iNode, iAttr, strName;
var iNodeParent = doc;

Expand Down Expand Up @@ -4657,12 +4657,12 @@ function __parseLoop__(impl, doc, p, isWindowDocument) {
else if(iEvt == XMLP._NONE) { // no more events
//steven woods notes that unclosed tags are rejected elsewhere and this check
//breaks a table patching routine
/*if (iNodeParent == doc) { // confirm that we have recursed back up to root
break;
}
else {
throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
}*/
//if (iNodeParent == doc) { // confirm that we have recursed back up to root
// break;
//}
//else {
// throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
//}
break;

}
Expand Down Expand Up @@ -4711,7 +4711,7 @@ function __parseLoop__(impl, doc, p, isWindowDocument) {
}

}
};
};*/


/**
Expand Down Expand Up @@ -7939,7 +7939,7 @@ __extend__(HTMLTableElement.prototype, {
}
},

/*appendChild : function (child) {
appendChild : function (child) {

var tagName;
if(child.tagName){
Expand All @@ -7964,7 +7964,7 @@ __extend__(HTMLTableElement.prototype, {
}else{
$error('HTMLTableElement.appendChild => child.tagName should not be undefined here... Fix ME!');
}
},*/
},

get tBodies() {
return new HTMLCollection(this.getElementsByTagName("tbody"));
Expand Down Expand Up @@ -7995,8 +7995,7 @@ __extend__(HTMLTableElement.prototype, {
// the row is appended as the last row. If index is omitted
// or greater than the number of rows, an error will result
if (idx === -1 || idx === numRows) {
lastRow = rows[rows.length-1];
lastRow.parentNode.appendChild(inserted);
this.appendChild(inserted);
} else {
rows[idx].parentNode.insertBefore(inserted, rows[idx]);
}
Expand Down Expand Up @@ -8243,6 +8242,13 @@ var HTMLTableRowElement = function(ownerDocument) {
HTMLTableRowElement.prototype = new HTMLElement;
__extend__(HTMLTableRowElement.prototype, {

appendChild : function (child) {

var retVal = DOMNode.prototype.appendChild.apply(this, arguments);
retVal.cellIndex = this.cells.length -1;

return retVal;
},
// align gets or sets the horizontal alignment of data within cells of the row.
get align() {
return this.getAttribute("align");
Expand Down Expand Up @@ -8323,9 +8329,11 @@ __extend__(HTMLTableRowElement.prototype, {
}

this.insertBefore(cell, node);

cell.cellIndex = idx;

return cell;
},


deleteCell : function (idx) {
var elem = this.cells[idx];
Expand Down
2 changes: 1 addition & 1 deletion src/dom/element.js
Expand Up @@ -63,7 +63,7 @@ __extend__(DOMElement.prototype, {
}*/

// assign values to properties (and aliases)
attr.value = value;
attr.value = value + '';

// add/replace Attribute in NamedNodeMap
this.attributes.setNamedItem(attr);
Expand Down
16 changes: 8 additions & 8 deletions src/dom/implementation.js
Expand Up @@ -131,7 +131,7 @@ __extend__(DOMImplementation.prototype,{
* @return : DOMDocument
*/

function __parseLoop__(impl, doc, p, isWindowDocument) {
/*function __parseLoop__(impl, doc, p, isWindowDocument) {
var iEvt, iNode, iAttr, strName;
var iNodeParent = doc;
Expand Down Expand Up @@ -408,12 +408,12 @@ function __parseLoop__(impl, doc, p, isWindowDocument) {
else if(iEvt == XMLP._NONE) { // no more events
//steven woods notes that unclosed tags are rejected elsewhere and this check
//breaks a table patching routine
/*if (iNodeParent == doc) { // confirm that we have recursed back up to root
break;
}
else {
throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
}*/
//if (iNodeParent == doc) { // confirm that we have recursed back up to root
// break;
//}
//else {
// throw(new DOMException(DOMException.SYNTAX_ERR)); // one or more Tags were not closed properly
//}
break;
}
Expand Down Expand Up @@ -462,7 +462,7 @@ function __parseLoop__(impl, doc, p, isWindowDocument) {
}
}
};
};*/


/**
Expand Down
7 changes: 3 additions & 4 deletions src/html/table.js
Expand Up @@ -58,7 +58,7 @@ __extend__(HTMLTableElement.prototype, {
}
},

/*appendChild : function (child) {
appendChild : function (child) {

var tagName;
if(child.tagName){
Expand All @@ -83,7 +83,7 @@ __extend__(HTMLTableElement.prototype, {
}else{
$error('HTMLTableElement.appendChild => child.tagName should not be undefined here... Fix ME!');
}
},*/
},

get tBodies() {
return new HTMLCollection(this.getElementsByTagName("tbody"));
Expand Down Expand Up @@ -114,8 +114,7 @@ __extend__(HTMLTableElement.prototype, {
// the row is appended as the last row. If index is omitted
// or greater than the number of rows, an error will result
if (idx === -1 || idx === numRows) {
lastRow = rows[rows.length-1];
lastRow.parentNode.appendChild(inserted);
this.appendChild(inserted);
} else {
rows[idx].parentNode.insertBefore(inserted, rows[idx]);
}
Expand Down
11 changes: 10 additions & 1 deletion src/html/tr.js
Expand Up @@ -11,6 +11,13 @@ var HTMLTableRowElement = function(ownerDocument) {
HTMLTableRowElement.prototype = new HTMLElement;
__extend__(HTMLTableRowElement.prototype, {

appendChild : function (child) {

var retVal = DOMNode.prototype.appendChild.apply(this, arguments);
retVal.cellIndex = this.cells.length -1;

return retVal;
},
// align gets or sets the horizontal alignment of data within cells of the row.
get align() {
return this.getAttribute("align");
Expand Down Expand Up @@ -91,9 +98,11 @@ __extend__(HTMLTableRowElement.prototype, {
}

this.insertBefore(cell, node);

cell.cellIndex = idx;

return cell;
},


deleteCell : function (idx) {
var elem = this.cells[idx];
Expand Down
34 changes: 34 additions & 0 deletions test/unit/nu.validator.js
@@ -0,0 +1,34 @@
/**
* @author thatcher
*/

load('dist/env.rhino.js');

window.location = 'test/html/malformed.html';


var fixture = document.xml,
testhtml = '<!DOCTYPE html><html><head/><body><script>document.write("<a>efg");</script><p>abc</body></html>',
testfragment = '<div>this is a<strong>pig<div>oink oink!',
success = function(){
print(doc.xml);
};

var doc;
//Envjs.logLevel = Envjs.DEBUG;
doc = new DOMParser().parseFromString(testhtml);
print(doc.xml);


doc.body.innerHTML = testfragment;
print(doc.xml);


/*
var start = new Date().getTime();
for(var i=0;i<1000;i++){
parseHtmlDocument(trivial, document, null, null);
}
var stop = new Date().getTime();
print("1000 parses "+(stop-start));
*/

0 comments on commit 09e691c

Please sign in to comment.