vue 样式属性值中ssrNode的双转义

vvppvyoh  于 2022-10-28  发布在  其他
关注(0)|答案(4)|浏览(112)

版本

2.6.11

复制链接

https://github.com/kamilic/vue/tree/style-attr-escaped的最大值

重现步骤

您可以在Vue项目中的./test/ssr/ssr-string.spec.js处添加此单元测试。

it('should not double escape style attribute values', done => {
    renderVmWithOptions({
      template: `
<div>
<div style="background: url(https://foo.bar/foo.png) no-repeat center center;\nbackground-size: cover;"></div>
</div>
`
    }, result => {
      expect(result).toContain(`<div style="background: url(https://foo.bar/foo.png) no-repeat center center;background-size: cover;"></div>`)
      done()
    })
  });


克隆文库并检出到style-attr-escaped分支并运行。

npm run test:ssr

实验结果:

需要什么?

样式属性值中没有ssrNode的双转义

到底发生了什么?

样式属性将被转义
此问题可能与#7224有关;
#7224

hrirmatl

hrirmatl1#

我尝试将这一行(https://github.com/vuejs/vue/blob/dev/src/server/optimizing-compiler/modules.js#L109)更改为

return [{ type: RAW, value: ` style=${JSON.stringify(staticStyle.replace(/\n/g, ''))}` }];

它起作用了,但我不知道它的行为是否符合预期。

gdrx4gfi

gdrx4gfi3#

有什么消息吗?

xmjla07d

xmjla07d4#

有什么答复吗?

相关问题