html-uglify
Advanced tools
Comparing version 1.1.2 to 1.1.3
'use strict'; | ||
var postcss = require('postcss'); | ||
var cheerio = require('cheerio'); | ||
var Hashids = require('hashids'); | ||
var postcssSafeParser = require('postcss-safe-parser'); | ||
@@ -43,5 +43,5 @@ var ALPHABET = 'abcdefghijklmnopqrstuvwxyz'; | ||
default: | ||
value; | ||
break; | ||
} | ||
return this.whitelist.indexOf(value) >= 0; | ||
@@ -121,6 +121,7 @@ }; | ||
var keyLookup = ''; | ||
var toReplace; | ||
// handle #something | ||
if (selectorPart.indexOf('#') > -1) { | ||
var toReplace = selectorPart.replace(/\#/g, ''); | ||
toReplace = selectorPart.replace(/\#/g, ''); | ||
keyLookup = ['id', toReplace].join(LOOKUP_DELIMITER); | ||
@@ -131,3 +132,3 @@ } | ||
if (selectorPart.indexOf('.') > -1) { | ||
var toReplace = selectorPart.replace(/\./g, ''); | ||
toReplace = selectorPart.replace(/\./g, ''); | ||
keyLookup = ['class', toReplace].join(LOOKUP_DELIMITER); | ||
@@ -138,4 +139,3 @@ } | ||
if (selectorPart.indexOf('id=') > -1){ | ||
var toReplace = selectorPart.replace(/id=/g, ''); | ||
toReplace = toReplace.replace(/\"/g, ''); // remove quotes from "somevalue" | ||
toReplace = selectorPart.replace(/id=/g, '').replace(/\"/g, ''); // remove quotes from "somevalue" | ||
keyLookup = ['id', toReplace].join(LOOKUP_DELIMITER); | ||
@@ -146,3 +146,3 @@ } | ||
if (selectorPart.indexOf('class=') > -1) { | ||
var toReplace = selectorPart.replace(/class=/g, ''); | ||
toReplace = selectorPart.replace(/class=/g, ''); | ||
keyLookup = ['class', toReplace].join(LOOKUP_DELIMITER); | ||
@@ -153,3 +153,3 @@ } | ||
if (selectorPart.indexOf('for=') > -1){ | ||
var toReplace = selectorPart.replace(/for=/g, ''); | ||
toReplace = selectorPart.replace(/for=/g, ''); | ||
toReplace = toReplace.replace(/\"/g, ''); // remove quotes from "somevalue" | ||
@@ -176,5 +176,5 @@ keyLookup = ['id', toReplace].join(LOOKUP_DELIMITER); | ||
$('style').each(function(index, element) { | ||
$('style').each(function() { | ||
var $style = $(this); | ||
var ast = postcss.parse($style.text(), { safe: true }); | ||
var ast = postcssSafeParser($style.text()); | ||
_this.processRules(ast.nodes, lookups); | ||
@@ -181,0 +181,0 @@ $style.text(ast.toString()); |
{ | ||
"name": "html-uglify", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Uglifies an HTML file and its associated CSS for compression. Great for HTML emails!", | ||
@@ -22,7 +22,7 @@ "main": "lib/main.js", | ||
"hashids": "^1.0.2", | ||
"postcss": "^4.1.16" | ||
"postcss-safe-parser": "^1.0.1" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.2.0", | ||
"mocha": "^2.2.5" | ||
"chai": "^3.4.1", | ||
"mocha": "^2.3.4" | ||
}, | ||
@@ -29,0 +29,0 @@ "repository": { |
@@ -15,3 +15,3 @@ 'use strict'; | ||
beforeEach(function() { | ||
whitelist = ['#theid', '.theclass']; | ||
whitelist = ['#theid', '.theclass', '#★', '.★']; | ||
htmlUglify = new HTMLUglify({whitelist: whitelist}); | ||
@@ -31,2 +31,10 @@ }); | ||
}); | ||
it('returns true if id is in whitelist for a unicode character', function() { | ||
var whitelisted = htmlUglify.isWhitelisted('id', '★') | ||
assert.isTrue(whitelisted); | ||
}); | ||
it('returns true if class is in whitelist for a unicode character', function() { | ||
var whitelisted = htmlUglify.isWhitelisted('class', '★') | ||
assert.isTrue(whitelisted); | ||
}); | ||
}); | ||
@@ -33,0 +41,0 @@ describe('#rewriteStyles', function() { |
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
31054
399
+ Addedpostcss-safe-parser@^1.0.1
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhas-flag@1.0.0(transitive)
+ Addedjs-base64@2.6.4(transitive)
+ Addedpostcss@5.2.18(transitive)
+ Addedpostcss-safe-parser@1.0.7(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.03.2.3(transitive)
- Removedpostcss@^4.1.16
- Removedamdefine@1.0.1(transitive)
- Removedes6-promise@2.3.0(transitive)
- Removedjs-base64@2.1.9(transitive)
- Removedpostcss@4.1.16(transitive)
- Removedsource-map@0.4.4(transitive)