Remove use of getElementsByTagName and getElementsByClassName
Replace calls to these functions with querySelector and querySelectorAll
This commit is contained in:
@@ -27,7 +27,7 @@ jasmineRequire.HtmlReporter = function() {
|
||||
);
|
||||
getContainer().appendChild(htmlReporterMain);
|
||||
|
||||
symbols = find(".symbol-summary")[0];
|
||||
symbols = find(".symbol-summary");
|
||||
};
|
||||
|
||||
var totalSpecsDefined;
|
||||
@@ -97,10 +97,10 @@ jasmineRequire.HtmlReporter = function() {
|
||||
this.jasmineDone = function() {
|
||||
var elapsed = now() - startTime;
|
||||
|
||||
var banner = find(".banner")[0];
|
||||
var banner = find(".banner");
|
||||
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + elapsed / 1000 + "s"));
|
||||
|
||||
var alert = find(".alert")[0];
|
||||
var alert = find(".alert");
|
||||
|
||||
alert.appendChild(createDom("span", { className: "exceptions" },
|
||||
createDom("label", { className: "label", 'for': "raise-exceptions" }, "raise exceptions"),
|
||||
@@ -110,7 +110,7 @@ jasmineRequire.HtmlReporter = function() {
|
||||
type: "checkbox"
|
||||
})
|
||||
));
|
||||
var checkbox = find("input")[0];
|
||||
var checkbox = find("input");
|
||||
|
||||
checkbox.checked = !env.catchingExceptions();
|
||||
checkbox.onclick = options.onRaiseExceptionsClick;
|
||||
@@ -129,7 +129,7 @@ jasmineRequire.HtmlReporter = function() {
|
||||
var statusBarClassName = "bar " + ((failureCount > 0) ? "failed" : "passed");
|
||||
alert.appendChild(createDom("span", {className: statusBarClassName}, statusBarMessage));
|
||||
|
||||
var results = find(".results")[0];
|
||||
var results = find(".results");
|
||||
results.appendChild(summary);
|
||||
|
||||
summaryList(topResults, summary);
|
||||
@@ -175,16 +175,16 @@ jasmineRequire.HtmlReporter = function() {
|
||||
createDom('a', {className: "spec-list-menu", href: "#"}, "Spec List"),
|
||||
createDom("span", {}, " | Failures ")));
|
||||
|
||||
find(".failures-menu")[0].onclick = function() {
|
||||
find(".failures-menu").onclick = function() {
|
||||
setMenuModeTo('failure-list');
|
||||
};
|
||||
find(".spec-list-menu")[0].onclick = function() {
|
||||
find(".spec-list-menu").onclick = function() {
|
||||
setMenuModeTo('spec-list');
|
||||
};
|
||||
|
||||
setMenuModeTo('failure-list');
|
||||
|
||||
var failureNode = find(".failures")[0];
|
||||
var failureNode = find(".failures");
|
||||
for (var i = 0; i < failures.length; i++) {
|
||||
failureNode.appendChild(failures[i]);
|
||||
}
|
||||
@@ -194,12 +194,7 @@ jasmineRequire.HtmlReporter = function() {
|
||||
return this;
|
||||
|
||||
function find(selector) {
|
||||
if (selector.match(/^\./)) {
|
||||
var className = selector.substring(1);
|
||||
return getContainer().getElementsByClassName(className);
|
||||
} else {
|
||||
return getContainer().getElementsByTagName(selector);
|
||||
}
|
||||
return getContainer().querySelector(selector);
|
||||
}
|
||||
|
||||
function createDom(type, attrs, childrenVarArgs) {
|
||||
|
||||
Reference in New Issue
Block a user