From 2213be632b4bf6ec28d06c63866fdd4e85c2adfc Mon Sep 17 00:00:00 2001 From: Cyril Mizzi Date: Wed, 14 Mar 2018 11:42:59 +0100 Subject: [PATCH] Revert "fixes style code" This reverts commit 89109a8f19e0dd6922d344481537fdfaf2cbe57b. --- __tests__/purgecssDefault.test.js | 13 +++++++------ src/index.js | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/__tests__/purgecssDefault.test.js b/__tests__/purgecssDefault.test.js index a7b4efcd..09cd8110 100644 --- a/__tests__/purgecssDefault.test.js +++ b/__tests__/purgecssDefault.test.js @@ -357,22 +357,23 @@ describe('purge methods with raw content and default extractor with whitelisted .double-class {color: black;}` } ], - whitelistPatterns: [ + whitelistPatterns : [ { - pattern: /^double-class$/, - keepChildren: true - } + pattern : /^double-class$/, + keepChildren : true + }, ] }).purge()[0].css }) - it('keeps double-class children', () => { + it ('keeps double-class children', () => { expect(purgecssResult.includes('.double-class test')).toBe(true) expect(purgecssResult.includes('.double-class.red')).toBe(true) expect(purgecssResult.includes('.double-class > .first-class')).toBe(true) }) - it('removes double-class--black class because of $', () => { + it ('removes double-class--black class because of $', () => { expect(purgecssResult.includes('.double-class--black')).toBe(false) }) }) + diff --git a/src/index.js b/src/index.js index 6c380593..03dfe087 100644 --- a/src/index.js +++ b/src/index.js @@ -446,24 +446,24 @@ class Purgecss { getWhitelistedSelector(selector: string): Object { if (this.options.whitelist) { for (const item of this.options.whitelist) { - const isString = typeof item === 'string' - const pattern = isString ? item : item.pattern + const isString = (typeof item === 'string') + const pattern = (isString) ? item : item.pattern // Assert the pattern match the given selector if (pattern === selector) { - return isString ? { pattern: pattern } : item + return (isString) ? { pattern : pattern } : item } } } if (this.options.whitelistPatterns) { for (const item of this.options.whitelistPatterns) { - const isRegExp = item instanceof RegExp - const pattern = isRegExp ? item : item.pattern + const isRegExp = (item instanceof RegExp) + const pattern = (isRegExp) ? item : item.pattern // Assert the pattern match the given selector if (pattern.test(selector)) { - return isRegExp ? { pattern: pattern } : item + return (isRegExp) ? { pattern : pattern } : item } } } @@ -478,7 +478,7 @@ class Purgecss { */ hasSelectorKeepChildren(selector: string): Object { const whitelist = this.getWhitelistedSelector(selector) - return whitelist.hasOwnProperty('keepChildren') ? whitelist.keepChildren : false + return (whitelist.hasOwnProperty('keepChildren')) ? whitelist.keepChildren : false } }