MohammadYounes / rtlcss

Framework for transforming Cascading Style Sheets (CSS) from Left-To-Right (LTR) to Right-To-Left (RTL)
https://rtlcss.com
MIT License
1.68k stars 129 forks source link

Updating `node.value` #85

Closed emilbayes closed 7 years ago

emilbayes commented 7 years ago

When using rtlcss as a processing step before other PostCSS plugin's I'm having issues with them picking up on changes made by rtlcss because of the way it updates the AST.

Consider the following css:

:root {
  --font-family-noto: 'Noto Sans', sans-serif /*rtl:prepend:'Noto Kufi Arabic', */;
}

body {
  font-family: var(--font-family-noto);
}

Processing:

postcss --use rtlcss --use postcss-custom-properties example.css

Output:

body {
  font-family: 'Noto Sans', sans-serif ;
}

This is due to rtlcss modifying the raw.value.raw css, while postcss-custom-properties reads the .value. I don't know which is more correct, I've just noted that lots of other PostCSS plugins mutate decl.value.

I can do a PR, but all it really takes is to append node.value = node.raws.value.raw after lib/rtlcss.js#L106

MohammadYounes commented 7 years ago

Sure, I think it will be safe to do this, since the value will be updated using the modified raw value.