Ignore HtmlReporter's createElement and createTextNode options
Injected DOM wrappers were a nice idea in theory but everyone just passes wrappers around document.createElement/document.createTextNode. That includes HtmlReporter's unit tests and karma-jasmine-html-reporter, the only known 5.x-compatible library that constructs an HtmlReporter.
This commit is contained in:
@@ -64,12 +64,6 @@
|
||||
getContainer: function() {
|
||||
return document.body;
|
||||
},
|
||||
createElement: function() {
|
||||
return document.createElement.apply(document, arguments);
|
||||
},
|
||||
createTextNode: function() {
|
||||
return document.createTextNode.apply(document, arguments);
|
||||
},
|
||||
timer: new jasmine.Timer(),
|
||||
filterSpecs: filterSpecs
|
||||
});
|
||||
|
||||
@@ -3,17 +3,8 @@ jasmineRequire.DomContext = function(j$) {
|
||||
|
||||
//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);
|
||||
const el = document.createElement(type);
|
||||
let children;
|
||||
|
||||
if (j$.private.isArray(childrenArrayOrVarArgs)) {
|
||||
@@ -30,7 +21,7 @@ jasmineRequire.DomContext = function(j$) {
|
||||
const child = children[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(this.createTextNode(child));
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
|
||||
@@ -104,10 +104,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
this.#env = options.env;
|
||||
|
||||
this.#getContainer = options.getContainer;
|
||||
this.#domContext = new j$.private.DomContext({
|
||||
createElement: options.createElement,
|
||||
createTextNode: options.createTextNode
|
||||
});
|
||||
this.#domContext = new j$.private.DomContext();
|
||||
this.#navigateWithNewParam =
|
||||
options.navigateWithNewParam || function() {};
|
||||
this.#urlBuilder = new UrlBuilder(
|
||||
@@ -852,7 +849,7 @@ jasmineRequire.HtmlReporter = function(j$) {
|
||||
|
||||
while (suite && suite.parent) {
|
||||
wrapper.insertBefore(
|
||||
this.#domContext.createTextNode(' > '),
|
||||
document.createTextNode(' > '),
|
||||
wrapper.firstChild
|
||||
);
|
||||
suiteLink = this.#domContext.create(
|
||||
|
||||
Reference in New Issue
Block a user