mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-10 17:38:41 +00:00
28 lines
673 B
JavaScript
28 lines
673 B
JavaScript
/**
|
|
* Add dom
|
|
*
|
|
* @param {Object} action Action data
|
|
* @param {function} callback Callback
|
|
* @param {string} id Action element
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
export function domAddElement (action, callback, id)
|
|
{
|
|
'use strict';
|
|
|
|
const e = action.base === 'self'
|
|
? (action.selector === '' || typeof action.selector === 'undefined'
|
|
? document.getElementById(id)
|
|
: document.getElementById(id).querySelector(action.selector))
|
|
: document.querySelector(action.selector);
|
|
|
|
for (const i in action.data) {
|
|
e.appendChild.removeChild(i);
|
|
}
|
|
|
|
if (typeof callback === 'function') {
|
|
callback();
|
|
}
|
|
};
|