Skip to content

In Vue components, a string literal inside a directive value keeps its character references (@click="msg = 'Tom & Jerry'") #313

Closed

Description

@JuroOravec

What happens

In a component that uses Vue, a string literal written inside a directive value keeps its character references as typed, while Vue decodes them. For example:

<button @click="msg = 'Tom &amp; Jerry'">Set</button>

sets msg to Tom &amp; Jerry; Vue's own compiler (@vue/compiler-dom 3.5.44) sets Tom & Jerry. The raw ; of the reference also makes Citry treat the handler as a statement block. The same happens in v-if, v-show, v-for, v-slot, v-model, v-text, v-memo and custom directive values.

Cause

Citry's patched Vize emitter (third_party/rust/vize_s1_to_s2/src/emit) reads these directive values as raw text (prefix::node_content), without the attribute-value decoding Vue applies to them.

Fix direction

Decode directive values by the attribute-value rule before they are parsed as JavaScript, as Vue does, for every directive kind, and decide whether a handler is a statement block from the decoded value.

Found while fixing #311.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions