What is the use of vnode in vue custom directive?

see an example,code at the bottom of the problem for permission control. If there are not enough permissions, there is no element.
I"d like to ask the hero to take a look at it:

  1. Why do you need to do
Object.defineProperty(comment, "setAttribute", {
      value: () => undefined,
    });

2 do not understand what vnode is and what is its use?

Vue.directive("permission", (el, binding, vnode) => {
  if (!isUserGranted(binding.value)) {
    // replace HTMLElement with comment node
    const comment = document.createComment(" ");
    Object.defineProperty(comment, "setAttribute", {
      value: () => undefined,
    });
    vnode.elm = comment;
    vnode.text = " ";
    vnode.isComment = true;
    vnode.context = undefined;
    vnode.tag = undefined;
    vnode.data.directives = undefined;

    if (vnode.componentInstance) {
      vnode.componentInstance.$el = comment;
    }

    if (el.parentNode) {
      el.parentNode.replaceChild(comment, el);
    }
  }
});
Mar.22,2021

  1. overrides the setAttribute method of the empty comment node (createComment) as a function that will not have any effect, probably to prevent subsequent operations from reporting errors, because originally it is a dom node, there must be operations on the attributes of dom, but the attribute cannot be set instead of a comment node. I don't know.
  2. vnode is a virtual node, and vnode can be used as the predecessor of the actual node creation. You see, if you replace the original elm with a comment node , you will not be able to create the original element. Stores some information about the node to be created, and the method used to create it. If the node-related information on the vnode is cleared or modified, the original node structure cannot be created.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b40d49-2c53d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b40d49-2c53d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?