forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOMImplementation.js
More file actions
91 lines (76 loc) · 2.78 KB
/
DOMImplementation.js
File metadata and controls
91 lines (76 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'use strict';
module.exports = DOMImplementation;
var Document = require('./Document');
var DocumentType = require('./DocumentType');
var HTMLParser = require('./HTMLParser');
var utils = require('./utils');
var xml = require('./xmlnames');
// Each document must have its own instance of the domimplementation object
function DOMImplementation(contextObject) {
this.contextObject = contextObject;
}
// Feature/version pairs that DOMImplementation.hasFeature() returns
// true for. It returns false for anything else.
var supportedFeatures = {
xml: { '': true, '1.0': true, '2.0': true }, // DOM Core
core: { '': true, '2.0': true }, // DOM Core
html: { '': true, '1.0': true, '2.0': true }, // HTML
xhtml: { '': true, '1.0': true, '2.0': true }, // HTML
};
DOMImplementation.prototype = {
hasFeature: function hasFeature(feature, version) {
var f = supportedFeatures[(feature || '').toLowerCase()];
return (f && f[version || '']) || false;
},
createDocumentType: function createDocumentType(qualifiedName, publicId, systemId) {
if (!xml.isValidQName(qualifiedName)) utils.InvalidCharacterError();
return new DocumentType(this.contextObject, qualifiedName, publicId, systemId);
},
createDocument: function createDocument(namespace, qualifiedName, doctype) {
//
// Note that the current DOMCore spec makes it impossible to
// create an HTML document with this function, even if the
// namespace and doctype are propertly set. See this thread:
// http://lists.w3.org/Archives/Public/www-dom/2011AprJun/0132.html
//
var d = new Document(false, null);
var e;
if (qualifiedName) e = d.createElementNS(namespace, qualifiedName);
else e = null;
if (doctype) {
d.appendChild(doctype);
}
if (e) d.appendChild(e);
if (namespace === utils.NAMESPACE.HTML) {
d._contentType = 'application/xhtml+xml';
} else if (namespace === utils.NAMESPACE.SVG) {
d._contentType = 'image/svg+xml';
} else {
d._contentType = 'application/xml';
}
return d;
},
createHTMLDocument: function createHTMLDocument(titleText) {
var d = new Document(true, null);
d.appendChild(new DocumentType(d, 'html'));
var html = d.createElement('html');
d.appendChild(html);
var head = d.createElement('head');
html.appendChild(head);
if (titleText !== undefined) {
var title = d.createElement('title');
head.appendChild(title);
title.appendChild(d.createTextNode(titleText));
}
html.appendChild(d.createElement('body'));
d.modclock = 1; // Start tracking modifications
return d;
},
mozSetOutputMutationHandler: function (doc, handler) {
doc.mutationHandler = handler;
},
mozGetInputMutationHandler: function (doc) {
utils.nyi();
},
mozHTMLParser: HTMLParser,
};