Skip to content

Commit fed9b52

Browse files
authored
Merge pull request #94 from KevinBatdorf/remove-import-statements
Remove @ globals
2 parents 55ccdfa + 6aab0b9 commit fed9b52

File tree

6 files changed

+790
-767
lines changed

6 files changed

+790
-767
lines changed

cypress/e2e/block.cy.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ context('Pattern Css', () => {
299299

300300
cy.previewCurrentPage();
301301

302-
// Confirm the same on the frontend
302+
// Confirm on the frontend
303303
cy.get(`.${className}`).should(
304304
'not.have.css',
305305
'background-image',
@@ -314,4 +314,42 @@ context('Pattern Css', () => {
314314
);
315315
});
316316
});
317+
it('Removes @import, @keyframes, and others', () => {
318+
const css = `@charset "UTF-8";
319+
@import url('https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css');
320+
@media screen and (max-width: 600px) { .f { foo: 'bar';} }
321+
@supports (display: grid) {}
322+
@page :left {}
323+
@font-face {font-family: MyFont;src: url('myfont.woff2');}
324+
@keyframes slidein {from {}to {}}
325+
@counter-style customCounter { system: cyclic; } `;
326+
cy.window().then((win) => {
327+
// Manually add blocks so we can get the block id
328+
const block = win.wp.blocks.createBlock('core/group', {}, [
329+
win.wp.blocks.createBlock('core/paragraph', {
330+
content: 'Hello',
331+
}),
332+
]);
333+
const className = `pcss-${block.clientId?.split('-')[0]}`;
334+
win.wp.data.dispatch('core/block-editor').insertBlock(block);
335+
336+
// Select the block
337+
cy.selectBlockById(block.clientId);
338+
cy.clearCodeFromCurrentBlock(); // clear placeholder
339+
cy.addCodeToCurrentBlock(css);
340+
341+
cy.previewCurrentPage();
342+
343+
// should not have any of the rules except media query
344+
cy.get(`style#pcss-block-${className}-inline-css`)
345+
.invoke('text')
346+
.should('not.contain', '@import')
347+
.and('not.contain', '@keyframes')
348+
.and('not.contain', '@charset')
349+
.and('not.contain', '@font-face')
350+
.and('not.contain', '@page')
351+
.and('not.contain', '@supports')
352+
.and('contain', '@media');
353+
});
354+
});
317355
});

0 commit comments

Comments
 (0)