Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document.createComment API #79

Open
xiaotiandada opened this issue Jun 20, 2021 · 0 comments
Open

document.createComment API #79

xiaotiandada opened this issue Jun 20, 2021 · 0 comments

Comments

@xiaotiandada
Copy link
Owner

https://developer.mozilla.org/zh-CN/docs/Web/API/Document/createComment

createComment() 方法用来创建并返回一个注释节点.

var commentNode = document.createComment('注释')

document.querySelector('body').appendChild(commentNode)

image

api 是在看 snabbdom 源码的时候发现的

// init.ts

const sel = vnode.sel;
if (sel === "!") {
  if (isUndef(vnode.text)) {
    vnode.text = "";
  }
  vnode.elm = api.createComment(vnode.text!);
}

h("!", "注释"),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant