diff --git a/CHANGES.md b/CHANGES.md
index 41559e0b1..341b927bc 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -48,11 +48,13 @@
- core dom: Add ``find_parents`` to find all parents of an element matching a CSS selector.
- core dom: Add ``find_scoped`` to search for elements matching the given selector within the current scope of the given element
- core dom: Add ``is_visible`` to check if an element is visible or not.
+- core dom: Add ``create_from_string`` to create a DOM Element from a string.
unless an ``id`` selector is given - in that case the search is done globally.
- pat date picker: Support updating a date if it is before another dependent date.
- pat tabs: Refactor based on ``ResizeObserver`` and fix problems calculating the with with transitions.
- pat tabs: When clicking on the ``extra-tabs`` element, toggle between ``open`` and ``closed`` classes to allow opening/closing an extra-tabs menu via CSS.
- pat autofocus: Do not autofocus in iframes. Fixes: #761.
+- pat inject: Allow configurable error pages. Can be disabled by adding ``pat-inject-errorhandler.off`` to the URL's query string.
### Technical
diff --git a/src/core/dom.js b/src/core/dom.js
index 3514a1ed0..66f0c9052 100644
--- a/src/core/dom.js
+++ b/src/core/dom.js
@@ -80,6 +80,13 @@ const is_visible = (el) => {
return el.offsetWidth > 0 && el.offsetHeight > 0;
};
+const create_from_string = (string) => {
+ // Create a DOM element from a string.
+ const div = document.createElement("div");
+ div.innerHTML = string.trim();
+ return div.firstChild;
+};
+
const dom = {
toNodeArray: toNodeArray,
querySelectorAllAndMe: querySelectorAllAndMe,
@@ -89,6 +96,7 @@ const dom = {
find_parents: find_parents,
find_scoped: find_scoped,
is_visible: is_visible,
+ create_from_string: create_from_string,
};
export default dom;
diff --git a/src/core/dom.test.js b/src/core/dom.test.js
index baf851fa4..b0f178262 100644
--- a/src/core/dom.test.js
+++ b/src/core/dom.test.js
@@ -249,4 +249,33 @@ describe("core.dom tests", () => {
done();
});
});
+
+ describe("create_from_string", () => {
+ it("Creates a DOM element from a string", (done) => {
+ let res = dom.create_from_string(`
+