ember-scoped-css 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/rewriteCss.js +8 -1
- package/test/rewriteCss.js +18 -0
package/package.json
CHANGED
package/src/rewriteCss.js
CHANGED
|
@@ -26,10 +26,17 @@ function rewriteSelector(sel, postfix) {
|
|
|
26
26
|
return transformed;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
function isInsideKeyframes(node) {
|
|
30
|
+
const parent = node.parent;
|
|
31
|
+
if (!parent) return false;
|
|
32
|
+
if (parent.type === 'atrule' && parent.name === 'keyframes') return true;
|
|
33
|
+
return isInsideKeyframes(parent);
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
module.exports = function rewriteCss(css, postfix, fileName) {
|
|
30
37
|
const ast = postcss.parse(css);
|
|
31
38
|
ast.walk((node) => {
|
|
32
|
-
if (node.type === 'rule') {
|
|
39
|
+
if (node.type === 'rule' && !isInsideKeyframes(node)) {
|
|
33
40
|
node.selector = rewriteSelector(node.selector, postfix);
|
|
34
41
|
}
|
|
35
42
|
});
|
package/test/rewriteCss.js
CHANGED
|
@@ -24,4 +24,22 @@ describe('rewriteCss', function () {
|
|
|
24
24
|
`/* foo.css */\n@layer components {\n\n.baz_postfix .foo p .bar_postfix { color: red; }\n}\n`
|
|
25
25
|
);
|
|
26
26
|
});
|
|
27
|
+
|
|
28
|
+
it.only('sudnt rewrite keyframes', function () {
|
|
29
|
+
const css = `
|
|
30
|
+
@keyframes luna-view-navigation {
|
|
31
|
+
100% {
|
|
32
|
+
padding-top: 1rem;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const postfix = 'postfix';
|
|
38
|
+
const fileName = 'foo.css';
|
|
39
|
+
const rewritten = rewriteCss(css, postfix, fileName);
|
|
40
|
+
|
|
41
|
+
expect(rewritten).to.equal(
|
|
42
|
+
`/* foo.css */\n@layer components {\n\n${css}\n}\n`
|
|
43
|
+
);
|
|
44
|
+
});
|
|
27
45
|
});
|