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

Double escaping of ssrNode in style attribute values #11449

Open
kamilic opened this issue Jun 10, 2020 · 4 comments
Open

Double escaping of ssrNode in style attribute values #11449

kamilic opened this issue Jun 10, 2020 · 4 comments

Comments

@kamilic
Copy link

kamilic commented Jun 10, 2020

Version

2.6.11

Reproduction link

https://github.com/kamilic/vue/tree/style-attr-escaped

Steps to reproduce

You can add this unit test at ./test/ssr/ssr-string.spec.js in Vue project.

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()
    })
  });

or

clone the library and checkout to style-attr-escaped branch and run.

npm run test:ssr

result:
image

What is expected?

No double escaping of ssrNode in style attribute values

What is actually happening?

style attribute will be escaped.


This issues may be related to #7224;
#7224

@kamilic
Copy link
Author

kamilic commented Jun 10, 2020

I tried to change this line (https://github.com/vuejs/vue/blob/dev/src/server/optimizing-compiler/modules.js#L109) to

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

It works, but I don't know it whether match expected behavior.

@kamilic kamilic changed the title Still double escaping of ssrNode in style attribute values Jun 10, 2020
@kamilic
Copy link
Author

kamilic commented Jun 20, 2020

any reply?????

@gaodeng
Copy link

gaodeng commented Sep 7, 2020

any news?

@kamilic
Copy link
Author

kamilic commented Sep 18, 2020

any reply??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants