Skip to content

Commit

Permalink
ADDED: proper doctype stringification
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpvar committed Feb 10, 2011
2 parents 2302ef4 + ea43446 commit adea6d6
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions lib/jsdom/level2/core.js
Expand Up @@ -491,16 +491,28 @@ core.DocumentType.prototype.__defineGetter__("internalSubset", function() {
});

core.DocumentType.prototype.toString = function() {
var dt = '<!doctype ' + this.name;
if (this.publicId && this.systemId) {
dt += 'public ' + this.publicId + ' ' + this.systemId;
dt = dt.toUpperCase();
if (this.ownerDocument._fullDT) {
return this.ownerDocument._fullDT;
}

var dt = '<!DOCTYPE ' + this.name;
if (this.publicId) {
// Public ID may never contain double quotes, so this is always safe.
dt += ' PUBLIC "' + this.publicId + '" ';
}
if (!this.publicId && this.systemId) {
dt += ' SYSTEM '
}
if (this.systemId) {
// System ID may contain double quotes OR single quotes, not never both.
if (this.systemId.indexOf('"') > -1) {
dt += "'" + this.systemId + "'";
} else {
dt += '"' + this.systemId + '"';
}
dt += '>';
if (this.ownerDocument._fullDT) {
dt = this.ownerDocument._fullDT;
}
return dt;
}
dt += '>';
return dt;
};

core.Document.prototype.importNode = function(/* Node */ importedNode,
Expand Down

0 comments on commit adea6d6

Please sign in to comment.