

import d from '@schematize/refs/browser/document.mjs';

//------------------------------------------------------------------------------
// document
//------------------------------------------------------------------------------
// create element
export const createElement = (...args) => d.createElement(...args);
// create element with namespace
export const createElementNS = (...args) => d.createElementNS(...args);
// create text node
export const createTextNode = (...args) => d.createTextNode(...args);
// create comment node
export const createComment = (...args) => d.createComment(...args);
// elementFromPoint
export const elementFromPoint = (...args) => d.elementFromPoint(...args);

//------------------------------------------------------------------------------
// node, parentNode functions
//------------------------------------------------------------------------------

// append children nodes
export const append = (parent, ...children) => parent.append(...children);
// before
export const before = (node, ...nodes) => node.before(...nodes);
// after
export const after = (node, ...nodes) => node.after(...nodes);
// replaceWith
export const replaceWith = (node, ...nodes) => node.replaceWith(...nodes);
// remove
export const remove = (node) => node.remove();
// setAttribute
export const setAttribute = (node, attribute, value) => node.setAttribute(attribute, value);
// setAttributeNS
export const setAttributeNS = (node, namespace, attribute, value) => node.setAttributeNS(namespace, attribute, value);

//------------------------------------------------------------------------------
// element, parentElement functions
//------------------------------------------------------------------------------

// append child element
export const appendChild = (parent, child) => parent.appendChild(child);

//------------------------------------------------------------------------------
// classList functions
//------------------------------------------------------------------------------

// classListToggle
export const classListToggle = (el, token, force) => el.classList.toggle(token, !!force);
// classListCondition
export const classListCondition = (el, token) => el.classList.contains(token);
// classListAdd
export const classListAdd = (el, ...args) => el.classList.add(...args);
// classListRemove
export const classListRemove = (el, ...args) => el.classList.remove(...args);
// classListReplace
export const classListReplace = (el, oldToken, newToken) => el.classList.replace(oldToken, newToken);