Comparing version 1.8.1 to 1.9.0
@@ -37,2 +37,3 @@ "use strict"; | ||
options = options || {}; | ||
var rules = utils.parseCSS(css); | ||
@@ -44,7 +45,7 @@ var editedElements = []; | ||
if (options && options.inlinePseudoElements) { | ||
if (options.inlinePseudoElements) { | ||
editedElements.forEach(inlinePseudoElements); | ||
} | ||
if (options && options.applyWidthAttributes) { | ||
if (options.applyWidthAttributes) { | ||
editedElements.forEach(function(el) { | ||
@@ -55,3 +56,3 @@ setDimensionAttrs(el, 'width'); | ||
if (options && options.applyHeightAttributes) { | ||
if (options.applyHeightAttributes) { | ||
editedElements.forEach(function(el) { | ||
@@ -62,6 +63,30 @@ setDimensionAttrs(el, 'height'); | ||
if (options && options.applyAttributesTableElements) { | ||
if (options.applyAttributesTableElements) { | ||
editedElements.forEach(setAttributesOnTableElements); | ||
} | ||
if (options.insertPreservedExtraCss && options.extraCss) | ||
{ | ||
var preservedText = utils.getPreservedText(options.extraCss, { | ||
mediaQueries: options.preserveMediaQueries, | ||
fontFaces: options.preserveFontFaces | ||
}); | ||
if (preservedText) | ||
{ | ||
var $appendTo = null; | ||
if (options.insertPreservedExtraCss !== true) | ||
{ | ||
$appendTo = $(options.insertPreservedExtraCss); | ||
} | ||
else | ||
{ | ||
$appendTo = $('head'); | ||
if (!$appendTo.length) { $appendTo = $('body'); } | ||
if (!$appendTo.length) { $appendTo = $.root(); } | ||
} | ||
$appendTo.first().append('<style>' + preservedText + '</style>'); | ||
} | ||
} | ||
function handleRule(rule) { | ||
@@ -139,3 +164,3 @@ var sel = rule[0]; | ||
var name = style[i]; | ||
var value = style[name] + (options && options.preserveImportant && style._importants[name] ? ' !important' : ''); | ||
var value = style[name] + (options.preserveImportant && style._importants[name] ? ' !important' : ''); | ||
var sel = style._importants[name] ? utils.importantSelector : selector; | ||
@@ -145,3 +170,3 @@ var prop = new utils.Property(name, value, sel); | ||
if (existing && existing.compare(prop) === prop || !existing) { | ||
if (existing && existing.compare(prop) === prop && !/\!important$/.test(existing.value) || !existing) { | ||
el.styleProps[name] = prop; | ||
@@ -148,0 +173,0 @@ } |
@@ -0,1 +1,6 @@ | ||
1.9.0 / 2016-01-04 | ||
================== | ||
* Add option `insertPreservedExtraCss` | ||
1.8.1 / 2015-12-01 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -36,2 +36,5 @@ "use strict"; | ||
def: "Add extra CSS" }, | ||
"insert-preserved-extra-css": { | ||
pMap: "insertPreservedExtraCss", | ||
def: "insert preserved @font-face and @media into document?" }, | ||
"apply-style-tags": { | ||
@@ -101,3 +104,3 @@ pMap: "applyStyleTags", | ||
var value = program[option.pMap]; | ||
if (value !== undefined) { | ||
if (value !== undefined) { | ||
if (option.pMap.match(/webResources/)) { | ||
@@ -104,0 +107,0 @@ result.webResources[option.map] = value; |
{ | ||
"name": "juice", | ||
"version": "1.8.1", | ||
"version": "1.9.0", | ||
"description": "Inlines css into html source", | ||
@@ -5,0 +5,0 @@ "bin": "bin/juice", |
@@ -53,3 +53,4 @@ [![Build Status](https://travis-ci.org/Automattic/juice.png?branch=master)](https://travis-ci.org/Automattic/juice) | ||
* `preserveMediaQueries` - preserves all media queries (and contained styles) within `<style></style>` tags as a refinement when `removeStyleTags` is `true`. Other styles are removed. Defaults to `false`. | ||
* `preserveFontFaces` - preserves all `@font-face` within `<style></style>` tags as a refinement when `removeStyleTags` is `true`. Other styles are removed. Defaults to `false`. | ||
* `preserveFontFaces` - preserves all `@font-face` within `<style></style>` tags as a refinement when `removeStyleTags` is `true`. Other styles are removed. Defaults to `false`. | ||
* `insertPreservedExtraCss` - whether to insert into the document any preserved `@media` or `@font-face` content from `extraCss` when using `preserveMediaQueries` or `preserveFontFaces`. When `true` order of preference to append the `<style>` element is into `head`, then `body`, then at the end of the document. When a `string` the value is treated as a CSS/jQuery/cheerio selector, and when found, the `<style>` tag will be appended to the end of the first match. Defaults to `false`. | ||
* `applyWidthAttributes` - whether to use any CSS pixel widths to create `width` attributes on elements set in `juice.widthElements`. Defaults to `false`. | ||
@@ -56,0 +57,0 @@ * `applyHeightAttributes` - whether to use any CSS pixel heights to create `height` attributes on elements set in `juice.heightElements`. Defaults to `false`. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
334184
880
203