Skip to content

Commit cacc8b7

Browse files
committed
Merge branch 'master' of https://github.com/Automattic/juice
2 parents 58cb71a + 32a0505 commit cacc8b7

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
[![Build Status](https://travis-ci.org/Automattic/juice.png?branch=master)](https://travis-ci.org/Automattic/juice)
2-
[![Dependency Status](https://david-dm.org/Automattic/juice.png)](https://david-dm.org/Automattic/juice)
1+
[![Build Status](https://travis-ci.org/Automattic/juice.svg?branch=master)](https://travis-ci.org/Automattic/juice)
2+
[![Dependency Status](https://david-dm.org/Automattic/juice.svg)](https://david-dm.org/Automattic/juice)
3+
34
# Juice ![](http://i.imgur.com/jN8Ht.gif)
45

56
Given HTML, juice will inline your CSS properties into the `style` attribute.
@@ -31,6 +32,7 @@ result will be:
3132

3233
* [node-email-templates][1] - Node.js module for rendering beautiful emails with [ejs][2] templates and email-friendly inline CSS using [juice][3].
3334
* [swig-email-templates][4] - Uses [swig][5], which gives you [template inheritance][6], and can generate a [dummy context][7] from a template.
35+
* [nodejs-api-starter][8] - A project template for building web APIs with Node.js and GraphQL (see [`src/emails`][9]).
3436

3537
[1]: https://github.com/niftylettuce/node-email-templates
3638
[2]: https://github.com/tj/ejs
@@ -39,6 +41,8 @@ result will be:
3941
[5]: https://github.com/paularmstrong/swig
4042
[6]: https://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance
4143
[7]: https://github.com/andrewrk/swig-dummy-context
44+
[8]: https://github.com/kriasoft/nodejs-api-starter
45+
[9]: https://github.com/kriasoft/nodejs-api-starter/tree/master/src/emails
4246

4347
## Documentation
4448

lib/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ exports.getPreservedText = function(css, options) {
9494
for (var i = rules.length - 1; i >= 0; i--) {
9595
if ((options.fontFaces && rules[i].type === 'font-face') ||
9696
(options.mediaQueries && rules[i].type === 'media')) {
97-
preserved.push(
97+
preserved.unshift(
9898
mensch.stringify(
9999
{ stylesheet: { rules: [ rules[i] ] }},
100100
{ comments: false, indentation: ' ' }

test/juice.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,9 @@ it('test style attributes and important priority', function() {
186186
juice.inlineContent('<div style="color: red !important;"></div>', 'div { color: black !important; }'),
187187
'<div style="color: red;"></div>');
188188
});
189+
190+
it('test that preserved text order is stable', function() {
191+
assert.deepEqual(
192+
utils.getPreservedText('div { color: red; } @media (min-width: 320px) { div { color: green; } } @media (max-width: 640px) { div { color: blue; } }', { mediaQueries: true }).replace(/\s+/g, ' '),
193+
' @media (min-width: 320px) { div { color: green; } } @media (max-width: 640px) { div { color: blue; } } ');
194+
});

0 commit comments

Comments
 (0)