Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] do not minify scripts with no type

  • Loading branch information...
commit c4525b391991028c456b8793fe8c04400ad42470 1 parent 1bb3d67
@Swaagie Swaagie authored
View
6 CHANGELOG.md
@@ -1,3 +1,9 @@
+## v0.5.2
+- [Fix] Make sure script without type=test/javascript is not minified
+
+## v0.5.1
+- [Fix] Improve tests against scripts
+
## v0.5.0
- [Major] Upgrade to htmlparser2 module for faster parsing and more options.
- [Major] Mimimize as constructor to allow multiple instances without infecting.
View
2  lib/helpers.js
@@ -137,7 +137,7 @@ Helpers.prototype.close = function close (element) {
* @api public
*/
Helpers.prototype.isJS = function isJS (element) {
- return (element.type === 'script' && !element.attribs)
+ return (element.type === 'script' && (!element.attribs || !element.attribs.type))
|| (element.type === 'script' && element.attribs.type === 'text/javascript');
};
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "minimize",
- "version": "0.5.1",
+ "version": "0.5.2",
"description": "Minimize HTML",
"main": "./lib/minimize",
"scripts": {
View
8 test/helpers-test.js
@@ -280,7 +280,13 @@ describe('Helpers', function () {
expect(helpers.isJS(html.inline)).to.be.false;
});
- it('returns true if type is script and attribute === null', function () {
+ it('returns true if type is script and has no attributes', function () {
+ html.script.attribs = {};
+ expect(helpers.isJS(html.script)).to.be.true;
+ });
+
+ it('returns true if type is script and has random attributes', function () {
+ html.script.attribs = { 'data-type': 'test' };
expect(helpers.isJS(html.script)).to.be.true;
});
Please sign in to comment.
Something went wrong with that request. Please try again.