Skip to content

Commit 56aae9f

Browse files
committed
Move non-standard serialization methods out of document
See jsdom#141. We still have to leave in the .innerHTML setter for now since it's basically used everywhere in the code base for parsing the document.
1 parent 049a523 commit 56aae9f

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/jsdom.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var createWindow = require('./jsdom/browser/index').createWindow;
1212
var browserAugmentation = require('./jsdom/browser/index').browserAugmentation;
1313
var windowAugmentation = require('./jsdom/browser/index').windowAugmentation;
1414

15+
var domToHtml = require('./jsdom/browser/domtohtml').domToHtml;
1516

1617
var request = function(options, cb) {
1718
request = require('request');
@@ -190,6 +191,12 @@ exports.env = exports.jsdom.env = function () {
190191
}
191192
};
192193

194+
exports.serializeDocument = function (doc, opts) {
195+
if (!opts) opts = {};
196+
197+
return domToHtml(opts.omitDoctype ? doc._childNodes : doc, true);
198+
};
199+
193200
function processHTML(config) {
194201
var options = {
195202
features: config.features,

lib/jsdom/browser/index.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,6 @@ var browserAugmentation = exports.browserAugmentation = function(dom, options) {
424424
}
425425
});
426426

427-
defineGetter(dom.Document.prototype, 'outerHTML', function() {
428-
return domToHtml(this, true);
429-
});
430-
431427
defineGetter(dom.Element.prototype, 'outerHTML', function() {
432428
return domToHtml(this, true);
433429
});
@@ -476,11 +472,6 @@ var browserAugmentation = exports.browserAugmentation = function(dom, options) {
476472
return html;
477473
});
478474

479-
480-
defineGetter(dom.Document.prototype, 'innerHTML', function() {
481-
return domToHtml(this._childNodes, true);
482-
});
483-
484475
defineSetter(dom.Document.prototype, 'innerHTML', function(html) {
485476
//Clear the children first:
486477
var child;

0 commit comments

Comments
 (0)