Skip to content

Commit

Permalink
breaking(core utils): Remove createElementFromHTML. Use create_from_s…
Browse files Browse the repository at this point in the history
…tring from Patternslib core dom instead.
  • Loading branch information
thet committed May 31, 2022
1 parent 0ecfb33 commit 7033e97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,6 @@ var storage = {
},
};

var createElementFromHTML = function (htmlString) {
// From: https://stackoverflow.com/a/494348/1337474
var div = document.createElement("div");
div.innerHTML = htmlString.trim();
return div.firstChild;
};

const ICON_CACHE = new Map();

/**
Expand Down Expand Up @@ -460,5 +453,4 @@ export default {
resolveIcon: resolveIcon,
setId: setId,
storage: storage,
createElementFromHTML: createElementFromHTML,
};
7 changes: 4 additions & 3 deletions src/pat/structure/js/views/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import $ from "jquery";
import _ from "underscore";
import _t from "../../../../core/i18n-wrapper";
import dom from "@patternslib/patternslib/src/core/dom";
import utils from "../../../../core/utils";
import logging from "@patternslib/patternslib/src/core/logging";
import Cookies from "js-cookie";
Expand Down Expand Up @@ -571,13 +572,13 @@ export default BaseView.extend({
return;
}

const el = utils.createElementFromHTML(
const el = dom.create_from_string(
this.statusTemplate({
label: status.label || "",
text: status.text,
type: status.type || "warning",
})
);
).lastChild;

if (btn) {
btn = $(btn)[0]; // support jquert + bare dom elements
Expand Down Expand Up @@ -614,7 +615,7 @@ export default BaseView.extend({
}
}
this.$el.append(
utils.createElementFromHTML('<div class="fc-status-container"></div>')
dom.create_from_string('<div class="fc-status-container"></div>')
);
if (this.columnsView) {
this.$el
Expand Down

0 comments on commit 7033e97

Please sign in to comment.