From 840dba990176e1a97f242f0482aa0bc91f40a7b3 Mon Sep 17 00:00:00 2001 From: Alexandre Gigliotti Date: Thu, 30 Jul 2015 09:13:39 -0700 Subject: [PATCH] Fixed bug where style attributes of elements outside a body element would not be inlined. --- lib/inline-style.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/inline-style.js b/lib/inline-style.js index 6fd7d25..cc6158a 100644 --- a/lib/inline-style.js +++ b/lib/inline-style.js @@ -14,22 +14,21 @@ var unwrap = function (value) { var inline = function (html, filename) { var files = []; var $ = cheerio.load(html, {decodeEntities: false}); - // style elements var styles = $('style'); styles.each(function (index, element) { var css = $(element).html(); - result = inlineUrl(css, filename); + var result = inlineUrl(css, filename); files.push(result.files); $(element).html(result.css); }); // style attributes - var attributes = $('body *').filter('[style]'); + var attributes = $('*').filter('[style]'); attributes.each(function (index, element) { var css = $(element).attr('style'); css = wrap(css); - result = inlineUrl(css, filename); + var result = inlineUrl(css, filename); files.push(result.files); css = string(result.css).collapseWhitespace().toString(); css = unwrap(css);