-
-
Notifications
You must be signed in to change notification settings - Fork 147
/
html-test-context.js
117 lines (117 loc) · 5.22 KB
/
html-test-context.js
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports", "@aurelia/debug", "@aurelia/kernel", "@aurelia/runtime", "@aurelia/runtime-html"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const debug_1 = require("@aurelia/debug");
const kernel_1 = require("@aurelia/kernel");
const runtime_1 = require("@aurelia/runtime");
const runtime_html_1 = require("@aurelia/runtime-html");
class HTMLTestContext {
constructor(config, wnd, Scheduler, UIEventType, EventType, CustomEventType, NodeType, ElementType, HTMLElementType, HTMLDivElementType, TextType, CommentType, DOMParserType, CSSStyleSheetType, ShadowRootType) {
this.config = config;
this.wnd = wnd;
this.Scheduler = Scheduler;
this.UIEvent = UIEventType;
this.Event = EventType;
this.CustomEvent = CustomEventType;
this.Node = NodeType;
this.Element = ElementType;
this.HTMLElement = HTMLElementType;
this.HTMLDivElement = HTMLDivElementType;
this.Text = TextType;
this.Comment = CommentType;
this.DOMParser = DOMParserType;
this.doc = wnd.document;
this.dom = new runtime_html_1.HTMLDOM(this.wnd, this.doc, NodeType, ElementType, HTMLElementType, CustomEventType, CSSStyleSheetType, ShadowRootType);
this._container = void 0;
this._scheduler = void 0;
this._templateCompiler = void 0;
this._observerLocator = void 0;
this._lifecycle = void 0;
this._renderer = void 0;
this._projectorLocator = void 0;
this._domParser = void 0;
}
get container() {
if (this._container === void 0) {
this._container = kernel_1.DI.createContainer(this.config);
kernel_1.Registration.instance(runtime_1.IDOM, this.dom).register(this._container);
kernel_1.Registration.instance(HTMLTestContext, this).register(this._container);
this._container.register(this.Scheduler);
this._container.register(debug_1.DebugConfiguration);
}
return this._container;
}
get scheduler() {
if (this._scheduler === void 0) {
this._scheduler = this.container.register(this.Scheduler).get(runtime_1.IScheduler);
}
return this._scheduler;
}
get templateCompiler() {
if (this._templateCompiler === void 0) {
this._templateCompiler = this.container.get(runtime_1.ITemplateCompiler);
}
return this._templateCompiler;
}
get observerLocator() {
if (this._observerLocator === void 0) {
this._observerLocator = this.container.get(runtime_1.IObserverLocator);
}
return this._observerLocator;
}
get lifecycle() {
if (this._lifecycle === void 0) {
this._lifecycle = this.container.get(runtime_1.ILifecycle);
}
return this._lifecycle;
}
get renderer() {
if (this._renderer === void 0) {
this._renderer = this.container.get(runtime_1.IRenderer);
}
return this._renderer;
}
get projectorLocator() {
if (this._projectorLocator === void 0) {
this._projectorLocator = this.container.get(runtime_1.IProjectorLocator);
}
return this._projectorLocator;
}
get domParser() {
if (this._domParser === void 0) {
this._domParser = this.doc.createElement('div');
}
return this._domParser;
}
static create(config, wnd, Scheduler, UIEventType, EventType, CustomEventType, NodeType, ElementType, HTMLElementType, HTMLDivElementType, TextType, CommentType, DOMParserType, CSSStyleSheetType, ShadowRootType) {
return new HTMLTestContext(config, wnd, Scheduler, UIEventType, EventType, CustomEventType, NodeType, ElementType, HTMLElementType, HTMLDivElementType, TextType, CommentType, DOMParserType, CSSStyleSheetType, ShadowRootType);
}
createElementFromMarkup(markup) {
this.domParser.innerHTML = markup;
return this.domParser.firstElementChild;
}
createElement(name) {
return this.doc.createElement(name);
}
createAttribute(name, value) {
const attr = this.doc.createAttribute(name);
attr.value = value;
return attr;
}
}
exports.HTMLTestContext = HTMLTestContext;
exports.TestContext = {
createHTMLTestContext() {
throw new Error('No createHTMLTestContext function has been provided. Did you forget to call initializeJSDOMTestContext() or initializeBrowserTestContext()?');
}
};
});
//# sourceMappingURL=html-test-context.js.map