domapi.js 970 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. export function createTextNode(text) {
  2. return document.createTextNode(text);
  3. }
  4. export function createComment(text) {
  5. return document.createComment(text);
  6. }
  7. export function insertBefore(parentNode, newNode, referenceNode) {
  8. parentNode.insertBefore(newNode, referenceNode);
  9. }
  10. export function removeChild(node, child) {
  11. node.removeChild(child);
  12. }
  13. export function appendChild(node, child) {
  14. node.appendChild(child);
  15. }
  16. export function parentNode(node) {
  17. return node.parentNode;
  18. }
  19. export function nextSibling(node) {
  20. return node.nextSibling;
  21. }
  22. export function tagName(elm) {
  23. return elm.tagName;
  24. }
  25. export function setTextContent(node, text) {
  26. node.textContent = text;
  27. }
  28. export function getTextContent(node) {
  29. return node.textContent;
  30. }
  31. export function isElement(node) {
  32. return node.nodeType === 1;
  33. }
  34. export function isText(node) {
  35. return node.nodeType === 3;
  36. }
  37. export function isComment(node) {
  38. return node.nodeType === 8;
  39. }