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

Compile function return comments (even if explicitly set "no comments" option) #3392

Closed
kospl opened this issue Mar 8, 2021 · 2 comments · Fixed by #4115
Closed

Compile function return comments (even if explicitly set "no comments" option) #3392

kospl opened this issue Mar 8, 2021 · 2 comments · Fixed by #4115
Labels

Comments

@kospl
Copy link

kospl commented Mar 8, 2021

Version

3.0.7

Reproduction link

https://jsfiddle.net/akgpf058/

Steps to reproduce

Vue.compile(`<h2>Todos:</h2><!-- COMMENT HERE -->`, {comments: false});

See result where comment nodes are in place (even with comments: false option):

(function anonymous(
) {
const _Vue = Vue
const { createVNode: _createVNode, createCommentVNode: _createCommentVNode } = _Vue

const _hoisted_1 = /*#__PURE__*/_createVNode("h2", null, "Todos:", -1 /* HOISTED */)

return function render(_ctx, _cache) {
  with (_ctx) {
    const { createVNode: _createVNode, createCommentVNode: _createCommentVNode, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock } = _Vue

    return (_openBlock(), _createBlock(_Fragment, null, [
      _hoisted_1,
      _createCommentVNode(" COMMENT HERE ")
    ], 2112 /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */))
  }
}
})

What is expected?

Returned result without comment nodes being rendered.

What is actually happening?

Comment nodes are in place: _createCommentVNode(" COMMENT HERE ")


I would appreciate any feedback on how to precompile template without comment nodes, my understanding that Vue has option to remove comment nodes from template, but I can be misreading source code, let me know if there any other way to make Vue.compile trim comments (there are should be one, I guess?).

@yyx990803
Copy link
Member

According to docs:

By default, Vue will remove HTML comments inside templates in production. Setting this option to true will force Vue to preserve comments even in production. Comments are always preserved during development.

This is intended behavior unless the comments are present in production.

Or is there any particular reason you want comments removed during development?

@kospl
Copy link
Author

kospl commented Jul 15, 2021 via email

yyx990803 pushed a commit that referenced this issue Jul 19, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.