-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
4,133 additions
and
2,269 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
coverage/ | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
|
||
coverage/ |
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,10 +1,5 @@ | ||
.editorconfig | ||
|
||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
yarn.lock | ||
|
||
coverage/ | ||
*.test.js | ||
.travis.yml | ||
coverage/ |
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 |
---|---|---|
|
@@ -2,7 +2,5 @@ language: node_js | |
cache: yarn | ||
node_js: | ||
- node | ||
- "8" | ||
- "6" | ||
git: | ||
depth: 5 | ||
- "12" | ||
- "10" |
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,13 +1,16 @@ | ||
var postcss = require('postcss') | ||
|
||
module.exports = postcss.plugin('postcss-will-change', function () { | ||
return function (css) { | ||
css.walkDecls('will-change', function (decl) { | ||
var already = decl.parent.some(function (i) { | ||
return i.type === 'decl' && i.prop === 'backface-visibility' | ||
}) | ||
if (already) return | ||
decl.cloneBefore({ prop: 'backface-visibility', value: 'hidden' }) | ||
}) | ||
module.exports = () => { | ||
return { | ||
postcssPlugin: 'postcss-will-change', | ||
Declaration: { | ||
'will-change': decl => { | ||
let already = decl.parent.some(i => { | ||
return i.type === 'decl' && i.prop === 'backface-visibility' | ||
}) | ||
if (!already) { | ||
decl.cloneBefore({ prop: 'backface-visibility', value: 'hidden' }) | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
module.exports.postcss = true |
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,33 +1,31 @@ | ||
var postcss = require('postcss') | ||
let postcss = require('postcss') | ||
|
||
var plugin = require('./') | ||
let plugin = require('./') | ||
|
||
function run (input, output) { | ||
return postcss([plugin]).process(input, { from: undefined }) | ||
.then(function (result) { | ||
expect(result.css).toEqual(output) | ||
expect(result.warnings()).toHaveLength(0) | ||
}) | ||
async function run (input, output) { | ||
let result = await postcss([plugin]).process(input, { from: undefined }) | ||
expect(result.css).toEqual(output) | ||
expect(result.warnings()).toHaveLength(0) | ||
} | ||
|
||
it('adds 3D hacks', function () { | ||
return run( | ||
it('adds 3D hacks', async () => { | ||
await run( | ||
'a{ will-change: transform; }', | ||
'a{ backface-visibility: hidden; will-change: transform; }' | ||
) | ||
}) | ||
|
||
it('does not override existing properties', function () { | ||
return run( | ||
it('does not override existing properties', async () => { | ||
await run( | ||
'a{ backface-visibility: visible; will-change: transform; }', | ||
'a{ backface-visibility: visible; will-change: transform; }' | ||
) | ||
}) | ||
|
||
it('does not get confused by other selectors', function () { | ||
var input = 'a{ backface-visibility: visible; } ' + | ||
'b { will-change: transform; }' | ||
var output = 'a{ backface-visibility: visible; } ' + | ||
'b { backface-visibility: hidden; will-change: transform; }' | ||
return run(input, output) | ||
it('does not get confused by other selectors', async () => { | ||
await run( | ||
'a{ backface-visibility: visible; } b { will-change: transform; }', | ||
'a{ backface-visibility: visible; } ' + | ||
'b { backface-visibility: hidden; will-change: transform; }' | ||
) | ||
}) |
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
Oops, something went wrong.