Skip to content

Commit

Permalink
Revert "fixes style code"
Browse files Browse the repository at this point in the history
This reverts commit 89109a8.
  • Loading branch information
Cyril Mizzi committed Mar 14, 2018
1 parent 706b3c1 commit 2213be6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 7 additions & 6 deletions __tests__/purgecssDefault.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

14 changes: 7 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand All @@ -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
}
}

Expand Down

0 comments on commit 2213be6

Please sign in to comment.