Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement *-of-type selectors. close #4.
- Loading branch information
Showing
8 changed files
with
259 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
------------|----------|----------|----------|----------|-------------------| | ||
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | | ||
------------|----------|----------|----------|----------|-------------------| | ||
All files | 96.73 | 87.69 | 100 | 96.61 | | | ||
All files | 96.71 | 87.98 | 100 | 96.6 | | | ||
css.js | 97.75 | 90 | 100 | 97.67 | 109,110 | | ||
dropcss.js | 99.14 | 97.5 | 100 | 99.07 | 163 | | ||
html.js | 100 | 96.15 | 100 | 100 | 60 | | ||
html.js | 98.82 | 94.12 | 100 | 98.77 | 104 | | ||
matches.js | 100 | 100 | 100 | 100 | | | ||
nth.js | 56.25 | 45 | 100 | 56.25 |... 38,41,47,52,54 | | ||
sel.js | 96.6 | 88.06 | 100 | 96.55 |... 09,114,121,223 | | ||
sel.js | 96.95 | 88.89 | 100 | 96.91 |... 10,115,122,246 | | ||
------------|----------|----------|----------|----------|-------------------| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,119 @@ | ||
const dropcss = require('../../src/dropcss.js'); | ||
const assert = require('assert'); | ||
|
||
/* e.g. | ||
.x .y + a:not(.y) | ||
.foo > bar:not([foo*=z]) | ||
*/ | ||
*/ | ||
|
||
describe('Context-aware, multi selector', () => { | ||
describe(':first-of-type', () => { | ||
it('should retain present', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img></div>', | ||
css: '.foo:first-of-type {}', | ||
}); | ||
assert.equal(out, '.foo:first-of-type{}'); | ||
}); | ||
|
||
it('should drop absent', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="bar"></span><img><span class="foo"></span><img></div>', | ||
css: '.foo:first-of-type {}', | ||
}); | ||
assert.equal(out, ''); | ||
}); | ||
}); | ||
|
||
describe(':last-of-type', () => { | ||
it('should retain present', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="bar"></span><span class="foo"></span><img></div>', | ||
css: '.foo:last-of-type {}', | ||
}); | ||
assert.equal(out, '.foo:last-of-type{}'); | ||
}); | ||
|
||
it('should drop absent', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img><span class="bar"></span><img></div>', | ||
css: '.foo:last-of-type {}', | ||
}); | ||
assert.equal(out, ''); | ||
}); | ||
}); | ||
|
||
describe(':only-of-type', () => { | ||
it('should retain present', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img></div>', | ||
css: '.foo:only-of-type {}', | ||
}); | ||
assert.equal(out, '.foo:only-of-type{}'); | ||
}); | ||
|
||
it('should drop absent', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img><span class="foo"></span><img></div>', | ||
css: '.foo:only-of-type {}', | ||
}); | ||
assert.equal(out, ''); | ||
}); | ||
}); | ||
|
||
describe('', () => { | ||
it('should retain present', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img></div>', | ||
css: '.foo:only-of-type {}', | ||
}); | ||
assert.equal(out, '.foo:only-of-type{}'); | ||
}); | ||
|
||
it('should drop absent', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img><span class="foo"></span><img></div>', | ||
css: '.foo:only-of-type {}', | ||
}); | ||
assert.equal(out, ''); | ||
}); | ||
}); | ||
|
||
describe(':nth-of-type()', () => { | ||
it('should retain present', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="bar"></span><img><span class="foo"></span><img></div>', | ||
css: '.foo:nth-of-type(2) {}', | ||
}); | ||
assert.equal(out, '.foo:nth-of-type(2){}'); | ||
}); | ||
|
||
it('should drop absent', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img><span class="bar"></span><img></div>', | ||
css: '.foo:nth-of-type(2) {}', | ||
}); | ||
assert.equal(out, ''); | ||
}); | ||
}); | ||
|
||
describe(':nth-last-of-type()', () => { | ||
it('should retain present', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="bar"></span><img><span class="foo"></span><img></div>', | ||
css: '.foo:nth-last-of-type(1) {}', | ||
}); | ||
assert.equal(out, '.foo:nth-last-of-type(1){}'); | ||
}); | ||
|
||
it('should drop absent', function() { | ||
let {css: out} = dropcss({ | ||
html: '<div><img><span class="foo"></span><img><span class="bar"></span><img></div>', | ||
css: '.foo:nth-last-of-type(1) {}', | ||
}); | ||
assert.equal(out, ''); | ||
}); | ||
}); | ||
}); |