Skip to content

Commit

Permalink
Removed stringToNodes
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha committed Dec 17, 2024
1 parent 7912542 commit 46b48ce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
14 changes: 2 additions & 12 deletions themes/bootstrap3/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ var VuFind = (function VuFind() {
return newElement;
}

/**
* Convert given string into a node list.
* @param {string} htmlString String to convert into nodes
* @returns {NodeList} Given string as a node list
*/
function stringToNodes(htmlString) {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = htmlString;
return tempDiv.childNodes;
}

// Event controls

let listeners = {};
Expand Down Expand Up @@ -348,7 +337,8 @@ var VuFind = (function VuFind() {
* @param {string} property Target property ('innerHTML', 'outerHTML' or '' for no HTML update)
*/
function setElementContents(elm, html, attrs = {}, property = 'innerHTML') {
const tmpDiv = el('div', '', {}, stringToNodes(html));
const tmpDiv = document.createElement('div');
tmpDiv.innerHTML = html;
const scripts = [];
// Cloning scripts wont work as they pass internal executed state so save them for later
tmpDiv.querySelectorAll('script').forEach(script => {
Expand Down
14 changes: 2 additions & 12 deletions themes/bootstrap5/js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,6 @@ var VuFind = (function VuFind() {
return newElement;
}

/**
* Convert given string into a node list.
* @param {string} htmlString String to convert into nodes
* @returns {NodeList} Given string as a node list
*/
function stringToNodes(htmlString) {
const tempDiv = document.createElement('div');
tempDiv.innerHTML = htmlString;
return tempDiv.childNodes;
}

// Event controls

let listeners = {};
Expand Down Expand Up @@ -348,7 +337,8 @@ var VuFind = (function VuFind() {
* @param {string} property Target property ('innerHTML', 'outerHTML' or '' for no HTML update)
*/
function setElementContents(elm, html, attrs = {}, property = 'innerHTML') {
const tmpDiv = el('div', '', {}, stringToNodes(html));
const tmpDiv = document.createElement('div');
tmpDiv.innerHTML = html;
const scripts = [];
// Cloning scripts wont work as they pass internal executed state so save them for later
tmpDiv.querySelectorAll('script').forEach(script => {
Expand Down

0 comments on commit 46b48ce

Please sign in to comment.