Skip to content

Commit db5432a

Browse files
committed
DRY. Introduce byId()
1 parent 7bc05d1 commit db5432a

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

docs/parse.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
function byId(id) {
2+
return document.getElementById(id);
3+
}
4+
15
/**
26
* @param {number} depth
37
* @return {string}
@@ -97,14 +101,14 @@ if (!("__defineGetter__" in {})) {
97101
errors.push("Object.prototype.__defineGetter__ isn’t supported");
98102
}
99103
if (errors.length) {
100-
document.getElementById("message").innerHTML = errors.join("<br>");
104+
byId("message").innerHTML = errors.join("<br>");
101105
document.body.className = "error";
102106
throw errors.join("\n\n");
103107
}
104108

105-
var style = document.getElementById("style");
106-
var output = document.getElementById("output");
107-
var serialized = document.getElementById("serialized");
109+
var style = byId("style");
110+
var output = byId("output");
111+
var serialized = byId("serialized");
108112

109113
function outputUpdated() {
110114
var value = style.value;

0 commit comments

Comments
 (0)