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

feat: implementing v-html transform #132

Closed
wants to merge 6 commits into from

Conversation

pikax
Copy link
Member

@pikax pikax commented Oct 6, 2019

v-html implementation

this is based on the current v-html implementation in v2

// template
<div v-html="testState"/>
// generated
export default function render() {
  const _ctx = this
  return (openBlock(), createBlock("div", { innerHTML: _ctx.testState }, null, 8 /* PROPS */, ["innerHTML"]))
}
// template
<div v-html="testState">Hello World!<p>test</p></div>
// generated
export default function render() {
  const _ctx = this
  return (openBlock(), createBlock("div", { innerHTML: _ctx.testState }, null, 8 /* PROPS */, ["innerHTML"]))
}

Advice and recommendations are welcome

@pikax pikax changed the title [WIP] feat: implementing v-html transform feat: implementing v-html transform Oct 6, 2019
@pikax pikax marked this pull request as ready for review October 6, 2019 16:12
Copy link
Member

@znck znck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of my comments on #130 apply here too.

dir.exp = createSimpleExpression('', true, loc)
}

// v-show can't be used outside of an element
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// v-show can't be used outside of an element
// v-html can't be used outside of an element

NodeTypes
} from '@vue/compiler-core'

export const transformHtml = createStructuralDirectiveTransform(
Copy link
Member

@yyx990803 yyx990803 Oct 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v-html (and v-text) shouldn't be structural directive transforms (The only structural directives are v-if and v-for). They should just be normal transforms mapping the directive to the corresponding prop.

@yyx990803
Copy link
Member

Really appreciate the PR but by directiveTransform I actually meant something like this: eadcaea#diff-939380a39655d7195a8a1c71675c6f8a

I noticed that previously directiveTransforms do not have access to the elementNode so I had to update its signature. Would you mind updating the v-text PR to mirror my commit? Thanks!

@yyx990803 yyx990803 closed this Oct 8, 2019
@pikax pikax deleted the v-html_implementation branch August 15, 2021 09:13
sxzz added a commit that referenced this pull request Aug 12, 2024
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
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

Successfully merging this pull request may close these issues.

3 participants