Created
December 14, 2015 01:58
-
-
Save dantman/7fa1338486b3f892b6de to your computer and use it in GitHub Desktop.
Juice styleFilter patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/client.js b/client.js | |
index 9deb594..44488de 100644 | |
--- a/client.js | |
+++ b/client.js | |
@@ -282,7 +282,7 @@ function inlineContent(html, css, options) { | |
function getStylesData($, options) { | |
var results = []; | |
var stylesList = $("style"); | |
- var styleDataList, styleData, styleElement; | |
+ var styleDataList, styleData, styleElement, filterResult; | |
stylesList.each(function () { | |
styleElement = this; | |
styleDataList = styleElement.childNodes; | |
@@ -290,6 +290,21 @@ function getStylesData($, options) { | |
return; | |
} | |
styleData = styleDataList[0].data; | |
+ if ( options.styleFilter ) { | |
+ filterResult = options.styleFilter(styleData, utils.extend({}, styleElement.attribs)); | |
+ if ( filterResult ) { | |
+ if ( filterResult.css ) { | |
+ styleData = filterResult.css; | |
+ } | |
+ if ( 'type' in filterResult ) { | |
+ if ( filterResult.type ) { | |
+ styleElement.attribs.type = filterResult.type; | |
+ } else { | |
+ delete styleElement.attribs.type; | |
+ } | |
+ } | |
+ } | |
+ } | |
if ( options.applyStyleTags && styleElement.attribs['data-embed'] === undefined ) { | |
results.push( styleData ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment