Decompose HtmlReporter into smaller components
This commit is contained in:
File diff suppressed because it is too large
Load Diff
54
src/html/DomContext.js
Normal file
54
src/html/DomContext.js
Normal file
@@ -0,0 +1,54 @@
|
||||
jasmineRequire.DomContext = function(j$) {
|
||||
'use strict';
|
||||
|
||||
//TODO maybe rename
|
||||
class DomContext {
|
||||
#createElement;
|
||||
|
||||
constructor(options = {}) {
|
||||
this.#createElement =
|
||||
options.createElement || document.createElement.bind(document);
|
||||
this.createTextNode =
|
||||
options.createTextNode || document.createTextNode.bind(document);
|
||||
}
|
||||
|
||||
create(type, attrs, childrenArrayOrVarArgs) {
|
||||
const el = this.#createElement(type);
|
||||
let children;
|
||||
|
||||
if (j$.private.isArray(childrenArrayOrVarArgs)) {
|
||||
children = childrenArrayOrVarArgs;
|
||||
} else {
|
||||
children = [];
|
||||
|
||||
for (let i = 2; i < arguments.length; i++) {
|
||||
children.push(arguments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(this.createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const attr in attrs) {
|
||||
if (attr === 'className') {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
}
|
||||
}
|
||||
|
||||
return DomContext;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ var jasmineRequire = window.jasmineRequire || require('./jasmine.js');
|
||||
|
||||
jasmineRequire.html = function(j$) {
|
||||
j$.private.ResultsNode = jasmineRequire.ResultsNode();
|
||||
j$.private.DomContext = jasmineRequire.DomContext(j$);
|
||||
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
||||
j$.QueryString = jasmineRequire.QueryString();
|
||||
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
||||
|
||||
Reference in New Issue
Block a user