From 3235c5350736d65403bba48014bc4ccd0c7ce196 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sun, 6 Nov 2016 16:47:44 +0800 Subject: [PATCH] fix no-useless-escape warnings from eslint 3.9.1 --- Gruntfile.js | 2 +- src/htmlminifier.js | 4 ++-- src/htmlparser.js | 4 ++-- tests/minifier.js | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 0f7cb53..d5f0c42 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -67,7 +67,7 @@ module.exports = function(grunt) { '$1(v<%= pkg.version %>)$2' ], './tests/index.html': [ - /("[^"]+\/qunit-)[0-9\.]+?(\.(?:css|js)")/g, + /("[^"]+\/qunit-)[0-9.]+?(\.(?:css|js)")/g, '$1<%= qunit_ver %>$2' ] }, diff --git a/src/htmlminifier.js b/src/htmlminifier.js index 4b78012..c5fee37 100644 --- a/src/htmlminifier.js +++ b/src/htmlminifier.js @@ -78,7 +78,7 @@ function collapseWhitespaceSmart(str, prevTag, nextTag, options) { } function isConditionalComment(text) { - return /^\[if\s[^\]]+\]|\[endif\]$/.test(text); + return /^\[if\s[^\]]+]|\[endif]$/.test(text); } function isIgnoredComment(text, options) { @@ -351,7 +351,7 @@ function unwrapMediaQuery(text) { } function cleanConditionalComment(comment, options) { - return options.processConditionalComments ? comment.replace(/^(\[if\s[^\]]+\]>)([\s\S]*?)()([\s\S]*?)(\/=]+)/, +var singleAttrIdentifier = /([^\s"'<>/=]+)/, singleAttrAssign = /=/, singleAttrAssigns = [singleAttrAssign], singleAttrValues = [ @@ -219,7 +219,7 @@ function HTMLParser(html, handler) { if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') { text = text .replace(//g, '$1') - .replace(//g, '$1'); + .replace(//g, '$1'); } if (handler.chars) { diff --git a/tests/minifier.js b/tests/minifier.js index 54495f0..f13c9af 100644 --- a/tests/minifier.js +++ b/tests/minifier.js @@ -1610,7 +1610,7 @@ QUnit.test('phrasing content with Web Components', function(assert) { // https://github.com/kangax/html-minifier/issues/10 QUnit.test('Ignore custom fragments', function(assert) { var input, output; - var reFragments = [/<\?[^\?]+\?>/, /<%[^%]+%>/, /\{\{[^\}]*\}\}/]; + var reFragments = [/<\?[^?]+\?>/, /<%[^%]+%>/, /\{\{[^}]*\}\}/]; input = 'This is the start. <% ... %>\r\n<%= ... %>\r\n\r\n\r\nNo comment, but middle.\r\n{{ ... }}\r\n\r\n\r\nHello, this is the end!'; output = 'This is the start. <% ... %> <%= ... %> No comment, but middle. {{ ... }} Hello, this is the end!'; @@ -2604,7 +2604,7 @@ QUnit.test('custom attribute collapse', function(assert) { output = '
foo
'; assert.equal(minify(input), input); - assert.equal(minify(input, { customAttrCollapse: /data\-bind/ }), output); + assert.equal(minify(input, { customAttrCollapse: /data-bind/ }), output); input = '
'; - assert.equal(minify(input, { customAttrCollapse: /ng\-class/ }), output); + assert.equal(minify(input, { customAttrCollapse: /ng-class/ }), output); }); QUnit.test('custom attribute collapse with empty attribute value', function(assert) { @@ -2638,7 +2638,7 @@ QUnit.test('custom attribute collapse with newlines, whitespace, and carriage re ' value2:false \n\r' + ' }">'; var output = '
'; - assert.equal(minify(input, { customAttrCollapse: /ng\-class/ }), output); + assert.equal(minify(input, { customAttrCollapse: /ng-class/ }), output); }); QUnit.test('do not escape attribute value', function(assert) { -- 2.34.1