mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-30 14:31:47 +00:00
28 lines
637 B
JavaScript
28 lines
637 B
JavaScript
/* Test Utilities */
|
|
function byId(id) {
|
|
return document.getElementById(id);
|
|
}
|
|
|
|
function make(htmlStr) {
|
|
var range = document.createRange();
|
|
var fragment = range.createContextualFragment(htmlStr);
|
|
var wa = getWorkArea();
|
|
for (var i = fragment.children.length - 1; i >= 0; i--) {
|
|
var child = fragment.children[i];
|
|
HTMx.processElement(child);
|
|
wa.appendChild(child);
|
|
}
|
|
return wa.lastChild;
|
|
}
|
|
|
|
function getWorkArea() {
|
|
return byId("work-area");
|
|
}
|
|
|
|
function clearWorkArea() {
|
|
getWorkArea().innerHTML = "";
|
|
}
|
|
|
|
function removeWhiteSpace(str) {
|
|
return str.replace(/\s/g, "");
|
|
} |