|
- 'use strict';
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = doctypeToString;
- function doctypeToString(doctype) {
- if (doctype === null) {
- return '';
- }
- // Checking with instanceof DocumentType might be neater, but how to get a
- // reference to DocumentType without assuming it to be available globally?
- // To play nice with custom DOM implementations, we resort to duck-typing.
- if (!doctype || doctype.nodeType !== doctype.DOCUMENT_TYPE_NODE || typeof doctype.name !== 'string' || typeof doctype.publicId !== 'string' || typeof doctype.systemId !== 'string') {
- throw new TypeError('Expected a DocumentType');
- }
- var doctypeString = '<!DOCTYPE ' + doctype.name + (doctype.publicId ? ' PUBLIC "' + doctype.publicId + '"' : '') + (doctype.systemId ? (doctype.publicId ? '' : ' SYSTEM') + (' "' + doctype.systemId + '"') : '') + '>';
- return doctypeString;
- }
|