mirror of
				https://github.com/KevinMidboe/inline-html.git
				synced 2025-10-29 17:40:29 +00:00 
			
		
		
		
	Fixed bug where style attributes of elements outside a body element would not be inlined.
This commit is contained in:
		| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user