inline-css
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -24,2 +24,3 @@ 'use strict'; | ||
} catch (err) { | ||
console.log(err); | ||
callback(err); | ||
@@ -26,0 +27,0 @@ } |
@@ -48,12 +48,18 @@ 'use strict'; | ||
var name = style[i], | ||
value = style[name], | ||
sel = style._importants[name] ? importantSelector : selector, | ||
prop = new Property(name, value, sel); | ||
value = style[name], | ||
sel = style._importants[name] ? importantSelector : selector, | ||
prop = new Property(name, value, sel), | ||
existing = el.styleProps[name], | ||
winner, | ||
loser; | ||
if ($(el).attr('style')) { | ||
var currentStyle = $(el).attr('style'); | ||
$(el).attr('style', currentStyle + ' ' + prop); | ||
if (existing) { | ||
winner = existing.compare(prop); | ||
loser = prop === winner ? existing : prop; | ||
if (winner === prop) { | ||
el.styleProps[name] = prop; | ||
} | ||
} else { | ||
el.styleProps[name] = prop; | ||
$(el).attr('style', prop); | ||
el.styleProps[name] = prop; | ||
} | ||
@@ -68,3 +74,3 @@ } | ||
if ($(el).attr('style')) { | ||
var cssText = '* { ' + el.getAttribute('style') + ' } '; | ||
var cssText = '* { ' + $(el).attr('style') + ' } '; | ||
addProps(parseCSS(cssText)[0][1], styleSelector); | ||
@@ -92,3 +98,3 @@ } | ||
}); | ||
//el.setAttribute('style', style.join(' ')); | ||
$(el).attr('style', style.join(' ')); | ||
} | ||
@@ -95,0 +101,0 @@ |
{ | ||
"name": "inline-css", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Inline css into an html file.", | ||
@@ -14,3 +14,3 @@ "main": "index.js", | ||
"scripts": { | ||
"test": "'echo \"Error: no test specified\" && exit 1'" | ||
"test": "gulp test" | ||
}, | ||
@@ -32,3 +32,11 @@ "repository": { | ||
}, | ||
"homepage": "https://github.com/jonkemp/inline-css" | ||
"homepage": "https://github.com/jonkemp/inline-css", | ||
"devDependencies": { | ||
"gulp": "^3.8.10", | ||
"gulp-jshint": "^1.9.0", | ||
"gulp-mocha": "^2.0.0", | ||
"gulp-util": "^3.0.2", | ||
"mocha": "^2.1.0", | ||
"should": "^4.6.1" | ||
} | ||
} |
@@ -7,2 +7,9 @@ # inline-css | ||
## Why inline-css instead of Juice? | ||
- Uses [cheerio](https://github.com/cheeriojs/cheerio) instead of jsdom | ||
- Works on Windows | ||
- Preserves Doctype | ||
- Modular | ||
- Gets your CSS automatically through style and link tags | ||
## How It Works | ||
@@ -66,3 +73,3 @@ | ||
inlineCss('/path/to/file.html', function(err, html) { | ||
inlineCss('/path/to/file.html', options, function(err, html) { | ||
console.log(html); | ||
@@ -74,3 +81,3 @@ }); | ||
### inlineCss(options) | ||
### inlineCss(html, options, callback) | ||
@@ -117,2 +124,9 @@ | ||
#### options.url | ||
Type: `String` | ||
Default: `filePath` | ||
How to resolve hrefs. Required. | ||
#### options.preserveMediaQueries | ||
@@ -119,0 +133,0 @@ |
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
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
10271
152
0
145
6