Debian Codegraph @

mixmark-io-domino/lib/DOMImplementation.js

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