From f361d36966631476ab4c7d51d75f3a0e379979d0 Mon Sep 17 00:00:00 2001 From: egavr Date: Wed, 16 Mar 2016 18:20:56 +0300 Subject: [PATCH 1/3] Add ignoring of duplicate 'css' classes --- lib/utils/utils.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utils/utils.js b/lib/utils/utils.js index aa69f41..72f1bc8 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -51,7 +51,11 @@ function sortCssClasses(attrs) { function _sortCssClassesValues(cssClasses) { var classList = (cssClasses || '').split(' '); - return _.filter(classList).sort().join(' '); + return _(classList) + .filter() + .uniq() + .sort() + .join(' '); } var classIndexes = _getIndexesInArray(attrs, 'class'); From f92a6818adcc8e2fbd0813081eeb545d5083d505 Mon Sep 17 00:00:00 2001 From: egavr Date: Wed, 16 Mar 2016 18:21:21 +0300 Subject: [PATCH 2/3] Add test cases on ignoring of duplicate 'css' classes --- test/differ/fixtures/second/sort-classes.html | 2 +- test/unit/utils.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/differ/fixtures/second/sort-classes.html b/test/differ/fixtures/second/sort-classes.html index 525f24a..dc06c25 100644 --- a/test/differ/fixtures/second/sort-classes.html +++ b/test/differ/fixtures/second/sort-classes.html @@ -1 +1 @@ - + diff --git a/test/unit/utils.js b/test/unit/utils.js index 97970a6..b5837eb 100644 --- a/test/unit/utils.js +++ b/test/unit/utils.js @@ -29,11 +29,13 @@ describe('\'utils\'', function () { { name: 'class', value: ' b c a' }, { name: 'blah', value: 'b c a' }, { name: 'class', value: '' }, + { name: 'class', value: 'a a a' } ], output = [ { name: 'class', value: 'a b c' }, { name: 'blah', value: 'b c a' }, - { name: 'class', value: '' } + { name: 'class', value: '' }, + { name: 'class', value: 'a' } ]; utils.sortCssClasses(input).must.be.eql(output); From 88dc25507a92552d815410b39d1b2c31baa0294c Mon Sep 17 00:00:00 2001 From: egavr Date: Wed, 16 Mar 2016 18:21:31 +0300 Subject: [PATCH 3/3] Add to README the info about the ignoring of duplicate 'css' classes --- README.md | 2 +- README.ru.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cd2f33a..4b1c4d4 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ For example, the following two code samples will be considered to be equivalent: ``` ```html -Text +Text ``` **CAUTION!**
diff --git a/README.ru.md b/README.ru.md index af9c6a0..adac42f 100644 --- a/README.ru.md +++ b/README.ru.md @@ -81,7 +81,7 @@ ``` ```html -Text +Text ``` **ВНИМАНИЕ!**