All files / runtime/src nodeOps.ts

100% Statements 56/56
100% Branches 10/10
100% Functions 8/8
100% Lines 56/56

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 571x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 44x 1x 1x 18x 1x 1x 21x 1x 1x 21x 1x 1x 45x 8x 45x 37x 37x 1x 1x 1x 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x  
import { RendererOptions } from '@vue/runtime-core'
import {
  INSVElement,
  INSVNode,
  NSVComment,
  NSVElement,
  NSVRoot,
  NSVText
} from './nodes'
 
export interface NSVNodeOps
  extends Omit<RendererOptions<INSVNode, INSVElement>, 'patchProp'> {
  createRoot(): NSVRoot
}
 
export const nodeOps: NSVNodeOps = {
  createRoot() {
    return new NSVRoot()
  },
  createComment(text) {
    return new NSVComment(text)
  },
  createElement(type, isSVG) {
    return new NSVElement(type)
  },
  createText(text) {
    return new NSVText(text)
  },
  nextSibling(node) {
    return node.nextSibling
  },
  parentNode(node) {
    return node.parentNode
  },
  insert(child, parent, anchor) {
    if (anchor !== null) {
      parent.insertBefore(child, anchor)
    } else {
      parent.appendChild(child)
    }
  },
  remove(el) {
    if (el.parentNode != null) {
      el.parentNode.removeChild(el)
    }
  },
  setElementText(node, text) {
    node.text = text
  },
  setText(node, text) {
    node.text = text
  },
  setScopeId(el, id) {
    el.setAttribute(id, '')
  }
}